Practical 7
Practical 7
• All files must include your name and student number at the very top of every file
(The ve concept). Marks will be subtracted for every missing occurrence.
• Your program must run.
• Code that is commented out is not marked.
• You must use comments to separate your program login. In other words, use
comments to mark the different sections of your code.
• Remember to breath and work through the practical one instruction at a time.
Notes:
• Create a method named TotalPrice that returns a decimal and accepts the quantity
of meal items ordered and the cost per meal as parameters. The method should
calculate and return the total price of the order as in Figure 3.
• Create a method named GenerateOrder that will not return anything and accepts a
decimal paramter. The method should prompt the user for the quanity of menu items
to order, calculate the total price, and display output as in Figure 3.
- You must call the TotalPrice method from within the GenerateOrder
method to calculate the total price of the meal order.
• Create a method called isAnotherOne that returns a bool. This method should
prompt the user for another customer order (See Figure 4) and return the bool result
of the user’s response.
1
• Use an appropriate loop to display the menu and the rest of the program. The loop
body should be executed at least once before the loop condition is checked.
- The loop should be controlled by the state of one of your custom methods.
• Use a switch structure to cycle through the menu options. For each case, you may
hard-code the price of the corresponding meal item in a variable.
- Do not create a new variable for each case. Rather, you must create one
variable to which you will assign a value in each case. Remember to take
variable scope into consideration. Ensure that you use the correct data type
for money.
- For each case, you must also call the GenerateOrder method.
- The default case should handle user error as in Figure 7.
2
Figure 3: Output generated – numbr of meals,
price per meal, and total price.
3
Figure 6: Output displayed due to user error –
user has a selected an option that is not on the
menu
4
Figure 8: User is prompted for next customer -
the user has selected ‘N’ and is allowed to exit
program.
Submission checklist
I have added a comment block with my information before the using directives.
I have used comments to separate my program logic.
I have zipped my entire solution folder and named it correctly: Surname (Student
number) where Surname and Student number is replaced with my own surname and
student number.
I have downloaded my zipped folder to check that I have submitted the correct project
folder (You must submit the entire project folder, not just the .sln file).