Question
Please Do Not Code entirely in main. Call on methods, and inherit the JFrame Assignment 4 You are to create an application for the Mt.
Please Do Not Code entirely in main. Call on methods, and inherit the JFrame
Assignment 4
You are to create an application for the Mt. SAC Morning Lift coffee shop that will help workers determine coffee purchases and total owed by customers. The coffee shop sells only Mochas, Lattes and drip coffee. You will display the types and/or quantities of coffees purchased in text area and the total of the customer in a JOptionPane or JLabel
Interface and Input:
2 JLabels one label containing your company name and second label containing you as the developer
Include the following individual input fields:
2 JTextFields one text field for Customer Name and other for quantity purchased
Type of coffee ordered (use JRadioButtons for the 3 possible types of coffee: mocha, latte, or drip)
3 JButtons as follows: one for processing the current coffee cost (Add to Order), one for displaying the total of all coffee purchases for this customer (Complete Order), and one for clearing the customer input (but not the text area)
JTextArea - Text area for displaying formatted purchase. (displayed when Add to Order clicked)
Display the subtotal, tax and grand total in a JOptionPane instead. (displayed when Complete Order is clicked)
Processing:
When the application starts display all of the components.
Create an invisible radio button that acts as the selected radio button at the beginning and reset the GUI to this setting after each purchase as part of the clear process. Also as part of the clear process, make sure the insertion point is placed in the first text field on the form (name text field).
Validate that something has been entered into name and quantity text fields and one of the valid coffee options is selected in a radio button. Do NOT calculate if your validation is not passed.
When the Add to Order button is pressed, calculate the cost of this coffee purchase.
This is done by calculating the cost based on the type of coffee times the quantity sold.
Each coffee type is a different price (make all of the prices constants).
Display the following in the text area, making sure that all data is properly labeled: customers name, quantity, type of coffee purchased, and cost of this coffee purchase.
When you display the coffee item bought, you must clear the all the input EXCEPT the name. (One client should be able to buy more than one item. E.g. 2 Lattes, and then 1 drip with add to order button when the order is done, complete order button is clicked for the total cost)
See the Extra Credit option for formatting, if desired. Do NOT remove the previous purchase before displaying the next purchase to be made in the text area.
Dont forget to accumulate your total so that you will be able to display the subtotal, tax and grand total for this customer correctly when the Complete Order button is pressed.
Reset the textfields or the radio buttons once Complete Order is pressed. Clear button is to allow clear the textfields when the user makes a mistake.
Allow an
Include a Complete Order button that will calculate the tax (based on a tax rate of 9.75%) of the total coffee purchase, add this to the sub total for the grand total owed by the customer, and display in a JOptionPane properly formatted with labeling information, such as Subtotal: , Tax: and Total Order Cost: . The text area should then be cleared for the next customer. If the extra credit option below is included, remember to redisplay the column headings in the text area.
Include a Clear button that will clear out all of the input fields and reset the radio buttons. Also ensure that the insertion point is placed in the first text field on the GUI. Do NOT clear out the text area EXCEPT at the end of your processing of the Complete Order button.
Ensure that you check to make sure that all input fields have some data entry and a valid selection is made of one of the radio buttons. Do NOT calculate if this validation is not passed!
All numeric literals must be defined as constants. This will include all of the coffee prices and the tax rate of .0975. The coffee prices that must be used are in the following table:
Coffee Type | Cost |
Mocha | $3.75 |
Latte | $3.25 |
Drip | $1.75 |
Output:
In the text area for the Add to Order button you should able to display as below and make sure that you have scrollbars so that all the data can be viewed
|
If you are going to do the extra credit option for the Add to Order button then the text area should display as shown below. Make sure you have scrollbars so that all the data can be viewed
|
When the Complete Order button is clicked you will be displaying subtotal, tax and the grand total in a JOptionPane, use your own judgment on the layout, but make it easy to read and ensure that it looks professional.
Additional Requirements:
Create and use constants for each coffee type unit price and the tax rate. Continue to use constants for the width and height of the frame.
Format all currency with a dollar sign and 2 decimal digits.
Extra Credit Option
For an extra 5 points, Make sure that your text area display uses the formatting process shown in class using the format method of the String class. See below (or the next page) for an example of how this should look. For full credit, your purchase information must line up correctly with both the headings and any previous purchases. For this to work best, make sure that you include and use a Courier font, which is a mono-spaced font.
Name: Qty Coffee Type Total
John Smith 1 Latte $3.50
John Smith 2 Mocha $7.50
For an additional 5 points of extra credit, add exception handling so that if the user enters non-numeric data in the quantity text field (or leaves the field empty), an appropriate reminder message will be displayed using a JOptionPane. Do NOT process the order if this occurs (no calculations or display of the order).
Reminders
Use correct naming conventions in your program. Indent the program source code correctly, leaving blank lines where appropriate.
Include the recommended remarks in the Java source code, both at the top of the class and before each method.
Also make sure that you fill out the top portion of the correct Evaluation Sheet (named correctly) and include that as part of your documentation. Dont forget to sign the evaluation sheet and add your hours to complete the project.
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