Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create the following method in the Receipt class public String getReceiptString() . This method should print all the item information for the Transaction, subtotal, tax,

image text in transcribedimage text in transcribedimage text in transcribed

Create the following method in the Receipt class public String getReceiptString() . This method should print all the item information for the Transaction, subtotal, tax, and total. o o It should be formatted like the following example: apple: 0.5 pear: 0.75 pineapple: 0.75 Subtota 1.25 Tax: Total. 0.08750 1.3375 Note that all the values for the subtotal, tax, and total fields are all aligned. You can achieve this by using the tab character ' Do not worry about always using 2 decimal places for now. Let the program decide how many decimal places to use. In the main method, create a Receipt object and pass it your previously created Tra from Part 1. Then print the result of the Receipt object's getReceiptString() method. Edit your getReceiptString method to include information about the Transaction's payment and change given back to the user. For each payment made by the user, output the type of the payment and the amount for that payment. The following is an example: apple: 0.5 pear: 0.75 pineapple: 0.75 Subtotal 2.0 Tax: Total: Debit: Cash: Change: 0.8599999999999999 In the main method, move your System.out.println(receipt.getReceiptString)) call to be below the call to Transaction.takePayment() 0.14 2.14 1.0 2.0 Create a class called Receipt. This class should have a private Transaction member. Write a getter method for this member, but not a setter. The only constructor for this class should be public Receipt(Transaction t), and the constructor should set the private Transaction member to the constructor's parameter. Create the following methods in the Transaction class public double computeSubTotal(0) o Given the list of items, set the sub-total (cost before tax) for the transaction, set the subTotal member to that value, and then return that value. Compute and set the tax for the list of items, and then return that value. Compute and set the overall total for the transaction, and then return that value. public double computeTax() o public double computeTotal() o

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions