"Our Prices Start at $11.99. As Our First Time Client, Use Coupon Code GET15 to claim 15% Discount This Month!!"
Focus on Software Engineering: Using Methods in a Menu-Driven Program
CONCEPT: Methods are ideal for use in menu-driven programs. When the user selects an item from a menu, the program can call the appropriate Method.
Write a menu-driven program for De Anza College Food Court. (You need to use Methods !)
- Display the food menu to a user (Just show the 5 options’ names and prices – No need to show the Combos or the details!)
- Use numbers for the options and for example “6” to exit.
- Ask the user what he/she wants and how many of it. (Check the user inputs) AND use trim() function to trim your inputs(if needed)
- Keep asking the user until he/she chooses the exit option.
You should have two classes, the first one is a driver class and the second one is the order class and includes these methods:
- A method to display the menu => displayMenu()
- A method to get inputs => getInputs()
- A method to calculate the tax and the bill => calculate(…..)
- A method to print the bill => printBill(….)
- You can use quantity1,quantity2,quantity3,quantity4,quantity5 to save the quantities of the burgers and put them inside an array
- You can use a constant array variable for the prices like priceArray = [5.25,5.75,5.95,5.95,5.95]
- Don’t forget to test your code with Positive and Negative Testing!
(For more information see this page Software Testing )
- Your code should have comments for each methods.
- Submit your code here.
Note: You can use your own code design and naming methods. Better designs will get better grades.
Note: It is a good design if your main method is short and you call other methods from the main method. It means, it is better to use different methods instead of putting all your code in the main method.
- Calculate the price.
- Ask the user whether he/she is a student or a staff. There is no tax for students and 9% tax for staffs. Add the tax price to the total price.
- Display the bill to the user. The bill includes:
- The food items
- The quantities
- The cost of them
- The total before tax
- Tax amount
- Total price after tax
You can have your own design but you need to have a main method and get started from the main method .
The name of methods also up to your design but the names should show what the methods do.
- Only display 2 decimal points when displaying all the numbers.
- Put at least two outputs (results after you run your code) at the end of your code as a multi-line comment.
- Don’t forget to put your name and a short description of your code on the top on your code.