Complete the Lotto.java lab we stated in the class. The purpose is to create a j
ID: 3844086 • Letter: C
Question
Complete the Lotto.java lab we stated in the class.
The purpose is to create a java class for "GA" Lottery Authority so that they can run the java application to generate a ticket.
(sample) Data fields:
(lotto) type
ticketNumber
idNumber
location
timeAndDate
Methods:
at leastt 2 Constructors Lotto()
pickN()
generateN()
getPurchaseDateTime()
checkAwardAmount()
(optional) print the whole ticket in a single method
#2 Design and code a JavaAccount.java class.
Data fields:
customerName
AccountNumber
balance
interestRate
and other additional information you may want to store in the JavaAccount.
Methods:
a Constructor JavaAccount()
deposit()
withdraw()
checkBalance()
setInterestRate()
checkInteretRate()
Explanation / Answer
import java.util.Scanner;
public class Account {
String customerName;
int AccountNumber;
double balance;
double interestRate;
Scanner scanner = new Scanner(System.in);
public Account(String customerName, int accountNumber, double balance,
double interestRate) {
this.customerName = customerName;
AccountNumber = accountNumber;
this.balance = balance;
this.interestRate = interestRate;
}
public Account() {
}
/**
* @return the customerName
*/
public String getCustomerName() {
return customerName;
}
/**
* @param customerName
* the customerName to set
*/
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
/**
* @return the accountNumber
*/
public int getAccountNumber() {
return AccountNumber;
}
/**
* @param accountNumber
* the accountNumber to set
*/
public void setAccountNumber(int accountNumber) {
AccountNumber = accountNumber;
}
/**
* @return the interestRate
*/
public double checkInterestRate() {
return interestRate;
}
/**
* @param interestRate
* the interestRate to set
*/
public void setInterestRate(double interestRate) {
this.interestRate = interestRate;
}
public void deposit() {
System.out.println("please enter deposit amount");
double depositAmount = scanner.nextDouble();
balance = balance + depositAmount;
System.out.println("your transaction is successful");
}
public void withdraw() {
System.out.println("please enter withdraw amount");
double withdrawAmount = scanner.nextDouble();
if (withdrawAmount > balance) {
System.out.println("insufficient funds ");
} else {
balance = balance + withdrawAmount;
System.out.println("your transaction is successful");
}
}
public void checkBalance()
{
System.out.println("the balance is " + balance);
}
}
********************************************************************************************
import java.util.Date;
public class Lotto {
String type;
int ticketNumber;
int idNumber;
String location;
Date timeAndDate;
public Lotto(String type, int ticketNumber, int idNumber, String location,
Date timeAndDate) {
this.type = type;
this.ticketNumber = ticketNumber;
this.idNumber = idNumber;
this.location = location;
this.timeAndDate = timeAndDate;
}
public Lotto() {
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
public String toString() {
return "Lotto [type=" + type + ", ticketNumber=" + ticketNumber
+ ", idNumber=" + idNumber + ", timeAndDate=" + timeAndDate
+ "]";
}
/**
* @return the location
*/
public String getLocation() {
return location;
}
/**
* @return the timeAndDate
*/
public Date getTimeAndDate() {
return timeAndDate;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.