I've finished the coding for the exercise, but I get this error and I don't know how to solve it.
Code:
/*1. Take the "menu program" you wrote earlier and break it out into a series of calls to functions for
each of the menu items. Add the calculator and "100 bottles of beer" as two different functions that can be called. */
#include <iostream>;
#include <string>;
using namespace std;
int food();
int westernfood();
int easternfood();
float calculator();
int drinks();
int hotdrinks();
int colddrinks();
float calculator(int food, float price)
{
float result = food * price;
return result;
}
int main()
{
int choice_main_menu = 0;
cout << "Welcome to Big Mama's restaurant. \n";
cout << "What would you like to order? (press 1 or 2) \n";
cout << "1. Food\n";
cout << "2. Drinks \n";
cin >> choice_main_menu;
switch (choice_main_menu)
{
case 1:
food();
break;
case 2:
drinks();
break;
default:
cout << "Invalid choice. \n";
}
system("pause");
return 0;
}
//FOOD
int food (int westernfood(), int easternfood())
{
int choice_food_menu = 0;
cout << "Which menu food would you like to choose from? ( choose 1 or 2 ) \n";
cout << "1. Western food \n";
cout << "2. Eastern food \n";
cin >> choice_food_menu;
switch (choice_food_menu)
{
case 1:
cout << westernfood();
break;
case 2:
cout << easternfood();
break;
default:
cout << "Invalid choices. \n";
}
return choice_food_menu;
}
int westernfood()
{
//food choices
int westernfood = 0;
int potato_chips;
int steak;
int bagels;
int donuts;
int hamburger;
cout << "Please select one of the following western food: \n";
cout << "1. Potato chips \n";
cout << "2. Steak \n";
cout << "3. Bagels \n";
cout << "4. Donuts \n";
cout << "5. Hamburgers \n";
cin >> westernfood;
switch ( westernfood )
{
case 1:
cout << "How many bag of potato chips would you like? \n";
cout << "( 1 bag - $2.50 ) \n"; // in this case, "bag" is food quantity, F, and $5 is the cash amount, C.
cin >> potato_chips;
cout << "That would be $" << calculator( potato_chips, 2.50 ) << ".\n";
break;
case 2:
cout << "How many dish(es) of steak would you like? \n";
cout << "( 1 dish - $7.20 ) \n";
cin >> steak;
cout << "That would be $" << calculator ( steak, 7.20 ) << ".\n";
break;
case 3:
cout << "How many bag of bagels would you like? \n";
cout << "( 1 bag - $3.00) \n";
cin >> bagels;
cout << "That would be $" << calculator ( bagels, 3.00 ) << ".\n";
break;
case 4:
cout << "How many bag of donuts would you like? \n";
cout << "( 1 bag - $3.50 )\n";
cin >> donuts;
cout << "That would be $" << calculator( donuts, 3.50 ) << ".\n";
break;
case 5:
cout << "How many hamburger(s) would you like? \n";
cout << "( 1 ham - 1.5 )\n";
cin >> hamburger;
cout << "That would be $" << calculator ( hamburger, 1.5 ) << ".\n";
break;
default:
cout << "Invalid choice. See above. \n";
}
return westernfood;
}
int easternfood()
{
int easternfood = 0;
int fish_balls;
int laksa;
int spring_rolls;
int dim_sum;
int fried_rice;
cout << "Please select one of the following western food \n";
cout << "1. Fish balls \n";
cout << "2. Laksa \n";
cout << "3. Spring rolls \n";
cout << "4. Dim sum \n";
cout << "5. Fried rice \n";
cin >> easternfood;
switch (easternfood)
{
case 1:
cout <<"How many bag of fish balls would you like? \n";
cout <<" ( 1 bag - $1.20 ) \n";
cin >> fish_balls;
cout <<"That would be $" << calculator ( fish_balls, 1.20 ) << ".\n";
break;
case 2:
cout <<"How many bowl of Laksa would you like? \n";
cout << " ( 1 bowl - $1.00 ) \n";
cin >> laksa;
cout << "That would be $" << calculator (laksa, 1.00) << ".\n";
break;
case 3:
cout << "How many bag of spring rolls would you like? \n";
cout << "( 1 bag - $1.50 )\n";
cin >> spring_rolls;
cout << "That would be $" << calculator(spring_rolls,1.50) << ".\n";
break;
case 4:
cout << "How many bowl of dim sum would you like? \n";
cout << " ( 1 bowl - 3.50 )\n";
cin >> dim_sum;
cout << "That would be $" << calculator (dim_sum, 3.50) << ".\n";
break;
case 5:
cout << "How many dish of fried rice would you like> \n";
cout << " ( 1 dish - $2.50) \n";
cin >> fried_rice;
cout << "That would be $" << calculator (fried_rice,2.50) << ".\n";
break;
default:
cout << "Invalid choice. \n";
}
return easternfood;
}
int drinks()
{
cout <<"Which menu of drinks would you like to choose from? ( 1 or 2 )\n";
cout <<"1. Hot drinks \n";
cout <<"2. Cold drinks \n";
int choice_drink_menu = 0;
cin >> choice_drink_menu;
switch (choice_drink_menu)
{
case 1:
cout << hotdrinks();
break;
case 2:
cout << colddrinks();
break;
default:
cout << "Invalid choice. See above. \n";
}
return choice_drink_menu;
}
int hotdrinks()
{
int hotdrinks = 0;
int hot_toddy;
int irish_coffee;
int bishop;
int cocoa;
int tea;
cout << "Please choose the hot drink you would like to order. \n";
cout << "1. Hot toddy \n";
cout << "2. Irish coffee \n";
cout << "3. Bishop \n";
cout << "4. Cocoa \n";
cout << "5. Tea \n";
cin >> hotdrinks;
switch (hotdrinks)
{
case 1:
cout <<"How many cup of hot toddy would you like? \n";
cout <<"( 1 cup - $2.20)\n";
cin >> hot_toddy;
cout << "That would be $" << calculator(hot_toddy, 2.20) << ".\n";
break;
case 2:
cout << "How many cup of irish coffee would you like? \n";
cin >> irish_coffee;
cout << "That would be $" << calculator(irish_coffee, 2.00) << ".\n";
break;
case 3:
cout << "How many cup of bishop would you like? \n";
cout << "( 1 cup - 3.00 ) \n";
cin >> bishop;
cout << "That would be $" << calculator(bishop, 3.00) << ".\n";
break;
case 4:
cout << "How many cup of cocoa would you like? \n";
cout << "( 1 cup - $2.50 ) \n";
cin >> cocoa;
cout << "That would be $" << calculator(cocoa, 2.50 ) << ".\n";
break;
case 5:
cout << "How many cup of tea would you like? \n";
cout << " ( 1 cup - $ 1.20 ) \n";
cin >> tea;
cout << "That would be $" << calculator(tea,1.20) << ".\n";
break;
default:
cout << "Invalid choice. See above. \n";
}
return hotdrinks;
}
int colddrinks()
{
int colddrinks;
int iced_lemon_tea;
int iced_milo;
int lemon_juice;
int apple_juice;
int orange_juice;
cout << "Please choose the cold drink you would like to order. \n";
cout << "1. Iced lemon tea \n";
cout << "2. Iced milo \n";
cout << "3. Lemon juice \n";
cout << "4. Apple juice \n";
cout << "5. Orange juice \n";
cin >> colddrinks;
switch (colddrinks)
{
case 1:
cout <<"How many cup of hot toddy would you like? \n";
cout <<"( 1 cup - $2.20)\n";
cin >> iced_lemon_tea;
cout << "That would be $" << calculator(iced_lemon_tea, 2.20) << ".\n";
break;
case 2:
cout << "How many cup of irish coffee would you like? \n";
cin >> iced_milo;
cout << "That would be $" << calculator(iced_milo, 2.00) << ".\n";
break;
case 3:
cout << "How many cup of bishop would you like? \n";
cout << "( 1 cup - 3.00 ) \n";
cin >> lemon_juice;
cout << "That would be $" << calculator(lemon_juice, 3.00) << ".\n";
break;
case 4:
cout << "How many cup of cocoa would you like? \n";
cout << "( 1 cup - $2.50 ) \n";
cin >> apple_juice;
cout << "That would be $" << calculator(apple_juice, 2.50 ) << ".\n";
break;
case 5:
cout << "How many cup of tea would you like? \n";
cout << " ( 1 cup - $ 1.20 ) \n";
cin >> orange_juice;
cout << "That would be $" << calculator(orange_juice,1.20) << ".\n";
break;
default:
cout << "Invalid choice. See above. \n";
}
return colddrinks;
}
These are the errors (or warnings?) I get:
1>------ Build started: Project: Food menu program, Configuration: Debug Win32 ------
1> food menu program.cpp
1>c:\users\user\documents\visual studio 2010\projects\food menu program\food menu program\food menu program.cpp(8): warning C4067: unexpected tokens following preprocessor directive - expected a newline
1>c:\users\user\documents\visual studio 2010\projects\food menu program\food menu program\food menu program.cpp(9): warning C4067: unexpected tokens following preprocessor directive - expected a newline
1>c:\users\user\documents\visual studio 2010\projects\food menu program\food menu program\food menu program.cpp(136): warning C4305: 'argument' : truncation from 'double' to 'float'
1>c:\users\user\documents\visual studio 2010\projects\food menu program\food menu program\food menu program.cpp(200): warning C4305: 'argument' : truncation from 'double' to 'float'
1>c:\users\user\documents\visual studio 2010\projects\food menu program\food menu program\food menu program.cpp(300): warning C4305: 'argument' : truncation from 'double' to 'float'
1>c:\users\user\documents\visual studio 2010\projects\food menu program\food menu program\food menu program.cpp(335): warning C4305: 'argument' : truncation from 'double' to 'float'
1>c:\users\user\documents\visual studio 2010\projects\food menu program\food menu program\food menu program.cpp(371): warning C4305: 'argument' : truncation from 'double' to 'float'
1>c:\users\user\documents\visual studio 2010\projects\food menu
program\food menu program\food menu program.cpp(406): warning C4305: 'argument' : truncation from 'double' to 'float'
1>food menu program.obj : error LNK2019: unresolved external symbol "int __cdecl food(void)" (?food@@YAHXZ) referenced in function _main
1>C:\Users\user\Documents\Visual Studio 2010\Projects\Food menu program\Debug\Food menu program.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Thank you