Please help me with this coding project. All .java programs you created for this
ID: 3841109 • Letter: P
Question
Please help me with this coding project.
All .java programs you created for this assignment can be in just one NetBeans project.
1) Define Customer.java according to the following class diagram and information. (6 points)
Customer
-customerID: int
- firstName: String
-lastName: String
+ Customer()
+ Customer(int, String, String)
+ getCustomerID(): int
+ setCustomerID(int)
+ getFirstName(): String
+ setFirstName(String)
+ getLastName(): String
+ setLastName(String)
+ toString(): String
• the first constructor doesn’t have any parameter and sets each of three instance variables to 0, null, and null, respectively;
• the second constructor uses three passed-in parameters to update values of the instance variables.
• toString() method return a String value for all instance variables of a Customer object. A sample return value of toString() for a Customer object is as follows.
Customer ID: 4838156 Name: John Smith
2) Define Account.java according to the following class diagram and information. (10 points)
Account
______________________________
- accountNo: int
- customer: Customer
- balance: double
______________________________
+ Account(int, Customer, double)
+ getAccountNo(): int
+ setAccountNo(int)
+ getCustomer(): Customer
+ setCustomer(Customer)
+ getBalance(): double
+ setBalance(double)
+ deposit(double)
+ withdraw(double): boolean
+ toString(): String
• the constructor uses three parameters to update values for accountNo, customer, and balance.
• deposit(double) uses value from the input parameter to update the existing balance (by adding the parameter’s amount to the existing balance).
• withdraw(double) reduces the current balance by the value of the input parameter. Return true if the current balance is not less than the parameter’s value and then reduces the existing balance accordingly; otherwise, return false and do not update the existing balance.
• toString() returns a String for all instance variable values of an Account object. A sample return value of toString() for an Order object is as follows.
Customer ID: 4838156 Name: John Smith Account Number: 5820389 Balance: $5,280.05
3) Define AccountApp.java according to following requirements to interact with the Customer and Account classes. (6 points)
• create a Customer object and make sure it has values for all its instance variables. Tip: you don’t need to use Scanner to collect input from keyboard. For simplicity, you can use hard-code values for parameters.
• call toString() method of Customer class and use system.out.println() to print out the returned value.
• create an Account object and make sure it has values for all its instance variables. Similarly, you can use hard-code parameter values.
• call deposit and withdraw methods of the Account object. Similarly, you can use hard-code parameter values as deposit and withdrawal amounts.
• call toString() method of Account class and use system.out.println() to print out the returned value.
4) In the following class diagram, Account was defined in the above step 2). Now define SavingAccount.java in which (8 points)
• the constructor uses four passed-in parameters to update values of all instance variables.
• toString() returns a String for all instance variable values of an SavingAccount object. A sample return value of toString() for an SavingAccount object is as follows. The interest rate has three decimal places.
Customer ID: 4838156 Name: John Smith Account Number: 5820389 Balance: $5,280.05Interest Rate: 2.750%
Account
- accountNo: int
- customer: Customer
- balance: double
+ Account(int, Customer, double)
+ getAccountNo(): int
+ setAccountNo(int)
+ getCustomer(): Customer
+ setCustomer(Customer)
+ getBalance(): double
+ setBalance(double)
+ deposit(double)
+ withdraw(double): boolean
+ toString(): String
SavingAccount
- interestRate: double
+ SavingAccount (int, Customer, double, double)
+ getInterestRate(): double + setInterestRate(double)
+ toString(): String
Al java progr you created for thi project. 11 Defi tomer java according to th lowing class diagra nd information. (6 point) String Nanni String Namel: Stri LatNamestringi he first construct ch of th doesn't h bles to 0, and null, respectively; nd construc hree passed-in pal meters to update values of th variables. ostring0 method bles of a Cust bject. A ing for a custo mer objectis as follows. return value to th Accountjava according to the following class diagram and information. 21 Defin 10 points he constructor uses three parameters to update values for accountNo, customer, and balance posit double) from the input param to update the existing balance (by adding the parameter's xisting bala withdrawldouble) redu balance by th lue of the input pari the current b he parameter's value and then reduces the existingbalance nce is not les accordingly; otherwise, return false and do not update the existing bala toStringl) returns String for al instance lues of bject. A of toStri Order object 838 156 nalla John SmithAnAc t Numbe 582 nBal 5, 280.05 3M Defi AccountApp.iava rding to following requ th the Custo Account cl 6 points te a Customer object and make sure it has values fo es. Tip: you don't its instance vari need to use Scanner to collect input from loeyboard. For simplicity, you can use hard-code valuesfor parameters. toString 0 thod of Custo system..outprintln0 ut the returned nt object and all its insta Similarly, yo rd-code pari ter values. call deposit and withdraw methods of the Account objec milarly, you nuse hard-code lues as deposit and with toString0 method of Account clas println D to print the ret ed val 4) In the following class diagra defined above step 20. Now defi SavingAccount which (8 points) of structor passed-in paramet to update val ostring0 returns a string for al instance variable values of a object. A sample lue of to 0 for Saving Ac follo The interest has three 838156 ohn Smith nluc 5820389 Bal. $5,280.05 Ace depasit(double) t witdraw doublek bool double SavingAce Cualamer, double, double)Explanation / Answer
Please find answer to first two parts: (3 and 4 images are not clear )
Customer.java
class Customer{
private int customerID;
private String firstName;
private String lastName;
public int getCustomerID() {
return customerID;
}
public void setCustomerID(int customerID) {
this.customerID = customerID;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public Customer(int customerID, String firstName, String lastName) {
this.customerID = customerID;
this.firstName = firstName;
this.lastName = lastName;
}
@Override
public String toString() {
return "Customer [customerID=" + customerID + ", firstName="
+ firstName + ", lastName=" + lastName + "]";
}
public Customer() {
this.customerID = 0;
this.firstName = null;
this.lastName = null;
}
}
Account.java
public class Account {
private int accountNo;
private Customer customer;
private double balance;
public Account() {
super();
}
public Account(int accountNo, Customer customer, double balance) {
super();
this.accountNo = accountNo;
this.customer = customer;
this.balance = balance;
}
public int getAccountNo() {
return accountNo;
}
public void setAccountNo(int accountNo) {
this.accountNo = accountNo;
}
public Customer getCustomer() {
return customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
@Override
public String toString() {
return "Account [accountNo=" + accountNo + ", customer=" + customer
+ ", balance=" + balance + "]";
}
public void deposit(double amnt)
{
this.balance+=amnt;
}
public boolean withdraw(double amnt)
{
boolean ret=false;
if(this.balance>amnt){
this.balance-=amnt;
ret=true;
}
return ret;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.