Write a fully documented Java program that uses the “Purchase” class from Chapter 5 of the Savitch textbook “Java, An Introduction to ProblemSolving & Programming, 8th ed.” (See p. 372,Programming Project 4, Savitch) Modify the Purchase class to allow currency formatted output byincluding 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. Theprogram is required to create five objects using the Purchase class methods for thefollowing 5 grocery items.object name group count group priceOranges: 10 $2.99Eggs: 12 $1.69Apples: 3 $1.00Watermelons: 1 $4.39Bagels: 6 $3.50The program should ask the user to indicate how many of each grocery item they wishto purchase. Using the appropriate Purchase class methods, the program shouldcalculate and display the cost of each grocery item purchase, and accumulate anddisplay the total bill. The output should be similar to the sample execution shown.Sample program execution:Enter the number of oranges being purchased24Enter the number of eggs being purchased36Enter the number of apples being purchased20Enter the number of watermelons being purchased2Enter the number of bagels being purchased12Thank you for shopping with CostSoLittle !24 orangesat 10 for $2.99Subtotal: $7.1836 eggsat 12 for $1.69Subtotal: $5.0720 applesat 3 for $1.00Subtotal: $6.672 watermelonsat 1 for $4.39Subtotal: $8.7812 bagelsat 6 for $3.50Subtotal: $7.00Total Cost for your purchases: $34.69
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here