Food and Drink

From CompSciWiki
Revision as of 16:10, 4 December 2011 by AdamW (Talk | contribs)

Jump to: navigation, search

Back to the Program-A-Day homepage

Problem

Write a program that will use Scanner to read in the price of a sandwich and a drink. Output the amounts. Calculate and output tax (assume 5% on everything). Then output a receipt as shown.
Sample output with sandwich 5.99 and drink 1.99:

 Cost of Sandwich:
 [DrJava Input Box]
Cost of Drink:
 [DrJava Input Box]
Food cost: 5.99
Drink cost: 1.99
Taxes: 0.399
Total: 8.379000000000001
Programmed by A. Student
**End of Program** 

Extra: Once you get this program working, try rounding the taxes to two decimal places.

 

Using Scanner for input

Wiki chars03.jpg

Solution

Code

Solution Code

Back to the Program-A-Day homepage