THINK FIRST·CODE LATER

← All labs

A café receipt with tabs

Problem

Write a class Receipt that prints this receipt for the campus café. Use \t (tabs) to align the prices, and let Java compute the total (12.00 + 18.50 + 3.00) instead of typing 33.5.

WKU CAMPUS CAFE
===============
Coffee		12.00
Sandwich	18.50
Water		3.00
---------------
Total		33.5
Items:		3
"Thank you!"

Why does Java print 33.5 and not 33.50? (You will fix this with printf in Chapter 4.)

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.