Question: Write a Java program that modifies and improves Programming Assignment 1 a . This version should disallow zero quantity orders ( management has decided that
Write a Java program that modifies and improves Programming Assignment a This version
should disallow zero quantity orders management has decided that everyone must buy at least
one sandwich and at least one beverage for supply cost reasons
Assume the convenience store only sells two items: beverages at $ each and sandwiches
at $ each. Prices can be hardcoded, but should be setstored in variables, and those
variables should be used in all calculations.
Prompt the user for the number of beverages and store the entered quantity as a decimal
number.
o If the quantity is positive, display the quantity and which item was ordered. If a positive
quantity is entered, output product and quantity. If the user enters a zero, display an
error message and ask the user, only once, for another quantity for that item.
Prompt the user for the number of sandwiches and store the entered quantity.
o If a positive quantity is entered, output the product and quantity. If the user enters a
zero, display an error message and ask the user, only once, for another quantity for that
item.
Only display the order total if the number of sandwiches is greater than zero and the number of
beverages is greater than zero. This should be executed with a nestedif statement or using
logical operators.
If both of those conditions are not met, display a message saying that management requires at
least one of each item being ordered. If they are met, display the subtotal, then the total with a
sales tax added do not worry about any extra decimals for now, as ugly as it will be
HINTSNOTES
Drawing a flowchart for the required behavior of this program will help you identify what types
of conditional statements to use, and when to use those statements. Pay attention to the
sample runs provided in the expected output and how they operate.
Depending on the tax calculation used, a differing number of decimal places may appear in
output. The method used for the expected output calculates percentage increasedecrease as a
multiplication times X with X being the percentage so something like tot sub for
as opposed to tot sub sub
If you are not using that style, it is likely going to involve differing decimal places. The other test
cases will not execute if any fail, so you should use the above tax calculation method.
Do not try to oversimply output in this problem. There will be times you may need to repeat
code to make this assignment work as shown.
There are multiple test cases that your code should pass if it handles everything correctly.
There are cases which produce a valid order, and cases that should produce errors For
simplicity, the inputs are grouped together in the Expected Output sections below:
Expected Output, valid input do NOT hard code your output:
Input: shown or or
Enter the number of beverages:
Ordered: beverages
Enter the number of sandwiches:
Ordered: sandwiches
The subtotal of beverages and sandwiches is $
With tax, the total is $
DIFFERENT TEST RUN BELOW
Input: or shown or
Enter the number of beverages:
ERROR: A quantity of zero is not allowed.
Enter the number of beverages:
Ordered: beverages
Enter the number of sandwiches:
Ordered: sandwiches
The subtotal of beverages and sandwiches is $
With tax, the total is $
DIFFERENT TEST RUN BELOW
Expected Output, invalid input do NOT hard code your output:
Input: shown or or
Enter the number of beverages:
ERROR: A quantity of zero is not allowed.
Enter the number of beverages:
Ordered: beverages
Enter the number of sandwiches:
Ordered: sandwiches
Your order total could not be calculated due to a zero quantity for an item
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
