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

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


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

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

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