Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is my program if anything is off lmk. public class Customer { private Strin

ID: 3606877 • Letter: T

Question

This is my program if anything is off lmk.

public class Customer {

private String firstName;

private String lastName;

private String accountNumber;

private String accountBalance;

//Constructors

public Customer(String fname, String lname)

{

   firstName = fname;

   lastName = lname;

}

   public Customer(String fname, String lname, String accNum, double bal)

   {

   firstName = fname;

   lastName = lname;

   accountNumber = accNum;

   accountBalance = bal;

   }

   // instance methods

   public void setfirstName(String fname)

   { firstName = fname; }

   public String getfirstName()

   { return firstName; }

  

   public void setCustomer(String cust)

   { return customer; }

   public void deposit(double amount)

   { accountBalance += amount; }

   public boolean equals(String acctnum)

   { return accountNumber.equals(acctnum); }

   public int CompareTo(Customer other)

   { int x = this.lastName.compareTo(other.lastName);

       if(x!=0) return x;

   x= this.lastName.compareTo(other.lastName);

       if(x!=0) return x;

   return(this.accountNumber).compareTo(other.accountNumber);

   }

  

I need help writing a tester for the program above. I only need one customer.

Java

1. Find a customer’s account by account number for deposits and withdrawals.
2. Find a customer’s account by searching for the customer’s name.
3. Deposit into an account, and show the new balance.
4. Withdraw from an account and show the new balance, if there is enough money!
5. Display a selected customer’s information.
6. Display all of the customers.

Explanation / Answer

Below is the code snippet in java for the Testing of data for single customer

import java.util.Scanner;
public void Test()
{
Scanner input = new Scanner(System.in);
  
//Menu driven Operations for Testing of operarions executed by Customer
//[As per condtion in the question this is for testing single customer only]
System.out.println("Enter '1' to Find a customer’s account by account number for deposits and withdrawals.");
System.out.println("Enter '2' to Find a customer’s account by searching for the customer’s name.");
System.out.println("Enter '3' to Deposit into an account, and show the new balance.");
System.out.println("Enter '4' to Withdraw from an account and show the new balance, if there is enough money!");
System.out.println("Enter '5' to Display a selected customer’s information.");
System.out.println("Enter '6' to Display all of the customers.");
int choice = input.nextInt();

switch(choice)
{
case 1:
System.out.println("Enter customer's account number:");
String cn = input.nextline();
if (accountNumber.equals(cn))
System.out.println(cn+" is the account no. of "+firstName+" "+lastName);
else
System.out.println("This account no. does not exist ! ");
break;

case 2:
System.out.println("Enter Customer First name");
String fn = input.nextline();
System.out.println("Enter Customer Last name");
String ln = input.nextline();
String n=fn+ln,o=firstName+lastName;
if(n.equalsIgnoreCase(o))
System.out.println(accountNumber+" is the account no. of "+firstName+" "+lastName);
else
System.out.println("This account no. does not exist ! ");
break;

case 3':
System.out.println("Enter account no:");
String cn = input.nextline();
System.out.println("Enter amount to be deposited:");
double a = input.nextDouble();
accountBalance+=a;
System.out.println("New Balance is:"+accountBalance);
break;

case 4:
System.out.println("Enter account no:");
String cn = input.nextline();
System.out.println("Enter amount to be withdrawn:");
double a = input.nextDouble();
if (a > accountBalance)
{
System.out.println("Balance is low ! Operation declined.");
break;
}
else
{
accountBalance-=a;
System.out.println("New Balance is:"+accountBalance);
break;
}
  
case 5:
System.out.println("Customer account no:"+accountNumber);
System.out.println("Customer name: "+firstName+" "+lastName);
System.out.println("Account Balance is: "+accountBalance);
break;

// Operation 6 is same as 5 because only one customer data is tested.
case 6:
System.out.println("Customer account no:"+accountNumber);
System.out.println("Customer name: "+firstName+" "+lastName);
System.out.println("Account Balance is: "+accountBalance);
break;
default:
System.out.println("Error");
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote