Support computing sales tax in the CashRegister class. The tax rate should be supplied when constructing a CashRegister object. Add recordTaxablePurchase and getTotalTax methods. (Amounts added with recordPurchase are not taxable.) The giveChange method should correctly reflect the sales tax that is charged on taxable items.  Please add the method to the CashRegisterTester. The input and output are also provided below.    CashRegister class: import java.util.Scanner; public class CashRegister {    private double purchase;    private double payment;    /**     Constructs a cash register with no money in it.     */    public CashRegister()    {        purchase = 0;        payment = 0;    }    /**     Records the sale of an item.     @param amount the price of the item     */    public void recordPurchase(double amount)    {        purchase = purchase + amount;    }    /**     Processes a payment received from the customer.     @param amount the amount of the payment     */    public void receivePayment(double amount)    {        payment = payment + amount;    }    /**     Computes the change due and resets the machine for the next customer.     @return the change due to the customer     */    public double giveChange()    {        double change = payment - purchase;        purchase = 0;        payment = 0;        return change;    }    //add method to print the receipt    public void printReceipt(){        System.out.println("Please enter each of the five items you have bought and their prices(the names of the items shouldn't contain any spaces):");        Scanner input = new Scanner(System.in);        int count = 0;        double totalAmount = 0;        String items = "";        String prices = "";        while (count < 5){            //get the item and its price from the customer            String item = input.next();            double price = input.nextDouble();            totalAmount += price;            //concat all items and prices            items = items.concat(item).concat(" ");            prices = prices.concat(String.valueOf(price)).concat(" ");            count++;        }        System.out.println(items);        System.out.println(prices);        System.out.println(totalAmount);    } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Java programming please 

 

Support computing sales tax in the CashRegister class. The tax rate should be supplied when constructing a CashRegister object. Add recordTaxablePurchase and getTotalTax methods. (Amounts added with recordPurchase are not taxable.) The giveChange method should correctly reflect the sales tax that is charged on taxable items.  Please add the method to the CashRegisterTester. The input and output are also provided below. 

 

CashRegister class:

import java.util.Scanner;

public class CashRegister {
   private double purchase;
   private double payment;

   /**
    Constructs a cash register with no money in it.
    */
   public CashRegister()
   {
       purchase = 0;
       payment = 0;
   }

   /**
    Records the sale of an item.
    @param amount the price of the item
    */
   public void recordPurchase(double amount)
   {
       purchase = purchase + amount;
   }

   /**
    Processes a payment received from the customer.
    @param amount the amount of the payment
    */
   public void receivePayment(double amount)
   {
       payment = payment + amount;
   }

   /**
    Computes the change due and resets the machine for the next customer.
    @return the change due to the customer
    */
   public double giveChange()
   {
       double change = payment - purchase;
       purchase = 0;
       payment = 0;
       return change;
   }
   //add method to print the receipt
   public void printReceipt(){
       System.out.println("Please enter each of the five items you have bought and their prices(the names of the items shouldn't contain any spaces):");
       Scanner input = new Scanner(System.in);
       int count = 0;
       double totalAmount = 0;
       String items = "";
       String prices = "";
       while (count < 5){
           //get the item and its price from the customer
           String item = input.next();
           double price = input.nextDouble();
           totalAmount += price;
           //concat all items and prices
           items = items.concat(item).concat(" ");
           prices = prices.concat(String.valueOf(price)).concat(" ");
           count++;
       }
       System.out.println(items);
       System.out.println(prices);
       System.out.println(totalAmount);
   }
}
 

Input and Output: (see image attached)

1 | public class CarTester
2
3 public static void CarTester(String[] args)
{
USE12 c = new USE12(50);
c.addGas (20);
c.drive(100);
System.out.println("fuel remain: "+c.getGas ());
}
9
10
11 }
I
G U5P10R.java
GU5P10D.java
GU5P04R.java
E CashRegisterTester.java
9 CashRegister.java
ECarTester.java
Compile Messages
JGRASP Messages
Run /O
Interactions
----JGRASP exec: java CashRegisterTester
Please enter each of the five items you have bought and their prices(the names of the items shouldn't contain any spaces):
End
Clear
banana
0.54
Help
coke
2.50
smoothie
3,40
yogurt
» blueberry
4.48
banana coke smoothie yogurt blueberry
0.54 2.5 3.4 4.0 4.48
14.92
Transcribed Image Text:1 | public class CarTester 2 3 public static void CarTester(String[] args) { USE12 c = new USE12(50); c.addGas (20); c.drive(100); System.out.println("fuel remain: "+c.getGas ()); } 9 10 11 } I G U5P10R.java GU5P10D.java GU5P04R.java E CashRegisterTester.java 9 CashRegister.java ECarTester.java Compile Messages JGRASP Messages Run /O Interactions ----JGRASP exec: java CashRegisterTester Please enter each of the five items you have bought and their prices(the names of the items shouldn't contain any spaces): End Clear banana 0.54 Help coke 2.50 smoothie 3,40 yogurt » blueberry 4.48 banana coke smoothie yogurt blueberry 0.54 2.5 3.4 4.0 4.48 14.92
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY