hey, I'm having problems with coding this program. the output is not what i wanted. any ideas?
this is the question:
The manager of the Diner by the Valley restaurant plans to have a computer available for
students to place their orders when they enter the campus centre. They have a limited menu
selection available that includes sandwiches and drinks. The manager wants the computer screen
to allow the students to select from a list of available sandwich and drink options. A large board
is located on the wall at the location where the computer will reside. It shows the menu of items
available and lists the price of each item.
In addition to white bread, they have whole wheat and rye bread. No charge is included for
different bread types; however, they do consider that selection a special request. The interface
should enable special requests such as bread types to be selected. Students should be able to
enter other special requests such as "Hold the onion" or "Hold the mayo". Water is available for
each order at no charge, but it must be ordered.
Prices are as follows:
• Sandwich = $2.00
• Tea = $1.80,
• Coffee = $2.30
• Juice = $1.50.
The manager needs a user-friendly interface where a student can choose options easily and at the
end, the program should display the current order selections and show the total cost of the order.
Refer to the scenario given above and write codes that make extensive use of selection
statements (if-else) to create a program for Diner by the Valley restaurant.
A student should be able to make various selections using the program e.g. selections for
sandwiches and drinks, bread types, drinks, make a special request etc. The total should contain
the total value of the order the student has to pay.
Also, include a do-while loop that asks the user whether he wants to place another order. The
user response of y or Y should allow for another transaction while any other response should
terminate the program.
this is my code:
using namespace std;
These variables are never set to a value - so when the are displayed they have whatever value happens to be in memory at their location. The functions return a value but the return value is never used. The return value needs to be assigned to a value. eg
menu = getMenuItems();
if (key = y )
variable y has again not been initialised - so could have any value. Also, this is an assignment not an equality test. = is assignment, == is equality test. Do you mean:
if (key == 'y')
and similar in other parts of the code.
It's good practice to always initialise a variable when it is defined.