Question
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
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started