Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Restaurant Bill Application implement a graphical application for creating a restaurant bill Should have a limited menu (at least five selections). The application must have

Restaurant Bill Application

implement a graphical application for creating a restaurant bill

Should have a limited menu (at least five selections).

The application must have the following functionality:

  • Add one of several different menu items to the check. An item can be added more than once
  • Once all the items have been added to the bill, total the bill, add tax, and add a tip
  • The user has an option to override the tax rate and tip rate
  • The user can clear the bill and start over
  • Once a bill has been totaled, no more items can be added to the bill, nor can it be totaled again

Your application should look like the following (approximately). The title of the Frame must be Restaurant Bill

image text in transcribed

Application Behavior

  • The bill area (where items are listed) initially starts out blank.
  • The user may change the Tax rate to any numeric value. The initial value is 5.6% (AZ Sales tax rate). Notice the labels before (Tax Rate) and after (%) the value.
  • The user may change the Tip rate to any numeric value. The initial value is 15.0%. Notice the labels before and after the value.
  • The application must have five or more food choices. They do not need to match the sample above. Also, the buttons can have an abbreviated version of the item name (e.g. C&S for Chips and Salsa). Each item must have an associate price.
  • When a food choice is selected, its description and price are added to the bill area. A food item may be added more than once (e.g. Cheesecake), or not at all (Fried Pickles).
  • If the Clear button is pressed, the bill area is cleared and the total zeroed out.
  • If the Total button is pressed, a Pretax total, Tax, Total with Tax, Tip and Total are calculated. o The Tax is based on the users tax rate (divided by 100) times the pretax total. o The Tip is also based on the pretax total, but uses the tip rate (divided by 100).
  • Once the bill has been totaled, no other food items may be added, nor can the bill be totaled again. Once the bill has been cleared, the food item and total buttons will work again.
  • The application will close when the window is closed (X in upper right-hand corner).
  • The bill should line up nicely and be scrollable for long orders. The example above is too short to show the scroll bars. The bill area should not be directly editable by the user.

Notes

  • You will likely have to fool around with the width and height of the frame and the number of rows and columns for the bill area to make the result look pleasing. You may also need to experiment with the font size (see below).
  • To make things line up nicely, you will have to use a couple tricks:

-Use String.format () to create Strings that have sharply defined field lengths

-Notice how the item description are left-justified while the prices are right justified

-Set the JTextArea to use a fixed-width font.

You can do this as follows:

billArea = new JTextArea(AREA_ROWS, AREA_COLUMNS);

Font font = new Font (Monospaced, Font.BOLD, 12);

billArea.setFont (font);

-Font is defined in java.awt

  • Required Main Class
    • FoodBill
  • Required Input
    • Any sequence of user entries in the tax rate or tip rate text boxes or button presses
  • Required Output
    • Your bill area should neatly list the items ordered with their prices and the totals, taxes and tip, as shown in the example above.
Restaurant Bill - Tax Rate 5.6 % Tip 15 % C&S Pickles Bacon Soup Cake Total Clear 4.69 10.69 Chips & Salsa Bacon Burger Cheesecake Fried Pickles Soup & Salad Cheesecake $ $ $ $ $ $ 6.99 6.49 7.79 6.99 43.64 Pretax Total Tax $ $ 2.44 Total w/Tax Tip $ $ 46.08 6.55 Total $ 52.63 Restaurant Bill - Tax Rate 5.6 % Tip 15 % C&S Pickles Bacon Soup Cake Total Clear 4.69 10.69 Chips & Salsa Bacon Burger Cheesecake Fried Pickles Soup & Salad Cheesecake $ $ $ $ $ $ 6.99 6.49 7.79 6.99 43.64 Pretax Total Tax $ $ 2.44 Total w/Tax Tip $ $ 46.08 6.55 Total $ 52.63

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions

Question

2. Compare the sales and service departments at Auto World.

Answered: 1 week ago