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

Your assignment is to create a file called Customer.java containing a class Cust

ID: 3801580 • Letter: Y

Question

Your assignment is to create a file called Customer.java containing a class Customer (there is no main method in this class). A Customer has a first name (a String), last name (String), ID number (integer), number of larger drinks (integer), number of small drinks (integer), and total cost (double). Each large drink costs $8.50 and each small drink costs $4.50. You need to compute the total cost based on the number of large drinks and small drinks.

The class Customer must include the following constructors and methods. (If your class does not contain any of the following methods, points will be deducted.)

Save the Customer class in a file called Customer. ava and use the following program stored in Assignment5java, which has the main method to create new Customer objects and to test your class. A sample output is shown below. Important Notes: Your class should have exactly the method headers that are described or otherwise your class will not work with the test driver program (Assignmen that is provided. You should never change the t5java) test driver program if the test driver is provided but instead make changes to Customer class to make it work. Helpful hints for doing this assignment: work on it in steps. Write one method, test it with a test driver and make sure it works before going on to the next method always make sure your code compiles before you add another method your methods should be able to be called in any order After compiling Customerjava file and Assignment5.java file, you need to execute Assignment5 class. Sample output (the nputs entered by a user are shown in boldD C: MyJava applications java Assignment5

Explanation / Answer

class Customer{
   String firstName,lastName;
   int customerID,noOFLargeDrinks,noOfSmallDrinks;
   double totalCost;
   double LARGE=8.50,SMALL=4.50;
   Customer(String fname,String lname,int ID,int ldrinks,int sdrinks){
       firstName=fname;
       lastName=lname;
       customerID=ID;
       noOFLargeDrinks=ldrinks;
       noOfSmallDrinks=sdrinks;
   }
   public void setFirstName(String fname){
       firstName=fname;
   }
   public void setLastName(String lname){
       lastName=lname;
   }
   public void setID(int ID){
       customerID=ID;
   }
   public void setNoOfLDrinks(int ldrinks ){
       noOFLargeDrinks=ldrinks;
   }
   public void setNoOfSDrinks(int sdrinks ){
       noOfSmallDrinks=sdrinks;
   }
   String getFirstName(){return firstName;}
   String getLastName(){return lastName;}
   int getID(){return customerID;}
   int getNoOfLDrinks(){return noOFLargeDrinks;}
   int getNoOFSDrinks(){return noOfSmallDrinks;}
   double getTotalCost(){
       return LARGE*noOFLargeDrinks+SMALL*noOfSmallDrinks;
   }
   public String toString(){
       return " FirstName "+this.getFirstName()+" Last Name "+this.getLastName()+" Customer ID " +this.getID()+" Number of Large Drinks "+this.getNoOfLDrinks()+
       " Number of Small Drinks "+this.getNoOFSDrinks()+" Total Cost "+getTotalCost();
   }
   public boolean equal(Customer o) {
// If the object is compared with itself then return true
if (o == this) {
return true;
}

/* Check if o is an instance of Complex or not
"null instanceof [type]" also returns false */
if (!(o instanceof Customer)) {
return false;
}
       Customer c = (Customer) o;
// Compare the data members and return accordingly
       return(
       firstName.equalsIgnoreCase(c.firstName)&&
       lastName.equalsIgnoreCase(c.lastName)&&
       customerID==c.customerID &&
       noOFLargeDrinks==c.noOFLargeDrinks &&
       noOfSmallDrinks==c.noOfSmallDrinks &&
Double.compare(totalCost, c.totalCost) == 0);
}
}

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