Write a program that uses the Purchase class in Listing 5.13 to set the following prices:

Oranges: 10 for $2.99
Eggs: 12 for $1.69
Apples: 3 for $1.00
Watermelons: $4.39 each
Bagels: 6 for $3.50

Then calculate the cost of each of the following five items and the total bill:
2 dozen oranges
3 dozen eggs
20 apples
2 watermelons
1 dozen bagels

This project does not specify how to input or display the information, so there are several ways it might be done. The solution in this manual “hard codes” the input data using set methods rather than entering it interactively via readInput(). In addition to the total cost of the items, the program outputs the subtotal cost for each item, along with its name and cost information.


See the code in Purchase.java and GroceryBill.java.

Computer Science & Information Technology

You might also like to view...

The printf() message must have at least one argument.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

You use the ____ section of the function's header to specify the data type of the value returned by the function.

A. Like B. Dim C. Type D. As dataType

Computer Science & Information Technology

Explain what a Sub procedure is and how it is coded, making sure to define the term procedure call in your response.

What will be an ideal response?

Computer Science & Information Technology

The ____________________ exception type occurs when a variable is converted to another type that is not possible.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology