Write a fully documented Java program that uses the “Purchase” class from Chapter 5 of the Savitch textbook “Java, An Introduction to Problem Solving & Programming, 8th ed.” (See p. 372, Programming...




Write a fully documented Java program that uses the “Purchase” class from Chapter 5 of the Savitch textbook “Java, An Introduction to Problem
Solving & Programming, 8th ed.” (See p. 372,
Programming Project 4, Savitch)
 Modify the Purchase class to allow currency formatted output by
including the following import statement:
import java.text.DecimalFormat;
Within the Purchase class, create a DecimalFormat object with the following format:
DecimalFormat Money = new DecimalFormat("$0.00");
Modify output for prices to reflect the currency format.
For example: System.out.println ("at " + groupCount +
" for " + Money.format(groupPrice));
DecimalFormat class and use the code shown above to format prices as currency. The
program is required to create five objects using the Purchase class methods for the
following 5 grocery items.
object name group count group price
Oranges: 10 $2.99
Eggs: 12 $1.69
Apples: 3 $1.00
Watermelons: 1 $4.39
Bagels: 6 $3.50
The program should ask the user to indicate how many of each grocery item they wish
to purchase. Using the appropriate Purchase class methods, the program should
calculate and display the cost of each grocery item purchase, and accumulate and
display the total bill. The output should be similar to the sample execution shown.
Sample program execution:
Enter the number of oranges being purchased
24
Enter the number of eggs being purchased
36
Enter the number of apples being purchased
20
Enter the number of watermelons being purchased
2
Enter the number of bagels being purchased
12
Thank you for shopping with CostSoLittle !
24 oranges
at 10 for $2.99
Subtotal: $7.18
36 eggs
at 12 for $1.69
Subtotal: $5.07
20 apples
at 3 for $1.00
Subtotal: $6.67
2 watermelons
at 1 for $4.39
Subtotal: $8.78
12 bagels
at 6 for $3.50
Subtotal: $7.00
Total Cost for your purchases: $34.69



Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here