Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Program Help There is an error in my code somewhere and I can't seem to understand how to fix it. I believe the error

C++ Program Help

There is an error in my code somewhere and I can't seem to understand how to fix it. I believe the error occurs when I try to pass an object to a function. The program is supposed to take user input for the member "restaurantNum" and pass it to the function "restaurantValidation" and generate a new object every time the program runs. NOTE: This is an unfinished project. The data types used must stay the same. Please simply fix the mistake so I may continue working on it! Thank you! (Screenshots and copy code below)

image text in transcribed

image text in transcribed

image text in transcribed

#include #include #include #include #include // Global Constants // Number of restaurants const int NUMHFCS = 8; // Number of tables in each restaurant const int HFCSIZES[NUMHFCS] = {19, 15, 24, 33, 61, 17, 55, 37}; // Names of restaurants const std::string RESTAURANT[NUMHFCS] = {"The Salubrious Bistro", "What the Kale?", "Lettuce Enjoy", "Vegan Nights", "Pasta is a Planet", "The Meatless Miracle", "The Pesky Pescatarian", "The Fine Fettle"};

class Restaurant { public: short int restaurantNum; short int tableNum; int patronNum; std::string patronName; char mealTime[]; short int mealNum;

} ;

void displayMenu(); void choiceValidation(int &); void restaurantValidation(short int &);

int main() { int menuChoice;

displayMenu(); choiceValidation(menuChoice);

if (menuChoice == 1) { Restaurant patron; std::cout

return 0; }

// Purpose: Display user interface // Pre-condition: N/A // Post-condition: N/A

void displayMenu() { std::cout

} // Purpose: Validate user initial menu choice // Pre-condition: Pass the menuChoice variable // Post-condition: Prompts user for valid choice or exits loop

void menuValidation(int &menuChoice) { bool controlFlag = true; do {

std::cin >> menuChoice;

if ((std::cin.fail()) || (menuChoice 6)) //|| (menuChoice > NUMHFCS))) { std::cout ::max(), ' '); } else { controlFlag = false; } } while (controlFlag); // End of do-while loop }

void restaurantValidation(short int patron.resaurantNum) { bool controlFlag = true; do { std::cin >> patron.restaurantNum;

if ((std::cin.fail()) || (patron.restaurantNum NUMHFCS)) { std::cout ::max(), ' '); } else { controlFlag = false; } } while (controlFlag); }

#include #include #include cest ring> const int NMHFCSB const int HECSIZESINUMEECS1-.15, 2.33. , 17. 55 37 const std: :string RESTAURANT [NUHI1ECS] " {"The S 1ubrious Bistro 13 "That the Kale?", Lertuce Entoy Vegan igha "Pasta is a Planet" 16 18 20 The Pesky scai" 23 pablio ahort int zeszaurantm short int tableNwn 25 2T 20 29 std: :8tring patronName char aeslTimeti 32 34 void displayena void choieva1idation (int void restaurantValidation(short int &); int main 43 int menuChoice: diaplayMena choicevslidation (nenuChOLCE) 45 86 87 7Purpose: validate user initial menu choice -condstion: PasS the menuchoice variable Post-condition: Prompts user for valid choice o exits Loop 89 90 void menuValidation (int &menuChoice) 92 93 94 95 96 97 98 bool controlFlagtrue; do std: :cin >> menuChoice; if ((std::cin.fail)) 11 (menuChoice 6)) 7711 (menuChoice >NUMHE std::cout: :max,n 01 02 03 04 05 06 07 08 09 10 11void restaurantValidation (short int patron.resaurantNum) 12 13 14 15 16 17 18 19 20 21 else controlFlag false while (controlFlag)IEnd of do-while 1oop bool controlFlagtrue; do std::cin >> patron.restaurantNum; if ((std: :oin. fail()) II (patron, restaurantNum NUMHFCS)) std::cout : :max () , ' ' ) ; 23 24 25 26 27 28 29 else contro!Flag false; while (controlFlag) #include #include #include cest ring> const int NMHFCSB const int HECSIZESINUMEECS1-.15, 2.33. , 17. 55 37 const std: :string RESTAURANT [NUHI1ECS] " {"The S 1ubrious Bistro 13 "That the Kale?", Lertuce Entoy Vegan igha "Pasta is a Planet" 16 18 20 The Pesky scai" 23 pablio ahort int zeszaurantm short int tableNwn 25 2T 20 29 std: :8tring patronName char aeslTimeti 32 34 void displayena void choieva1idation (int void restaurantValidation(short int &); int main 43 int menuChoice: diaplayMena choicevslidation (nenuChOLCE) 45 86 87 7Purpose: validate user initial menu choice -condstion: PasS the menuchoice variable Post-condition: Prompts user for valid choice o exits Loop 89 90 void menuValidation (int &menuChoice) 92 93 94 95 96 97 98 bool controlFlagtrue; do std: :cin >> menuChoice; if ((std::cin.fail)) 11 (menuChoice 6)) 7711 (menuChoice >NUMHE std::cout: :max,n 01 02 03 04 05 06 07 08 09 10 11void restaurantValidation (short int patron.resaurantNum) 12 13 14 15 16 17 18 19 20 21 else controlFlag false while (controlFlag)IEnd of do-while 1oop bool controlFlagtrue; do std::cin >> patron.restaurantNum; if ((std: :oin. fail()) II (patron, restaurantNum NUMHFCS)) std::cout : :max () , ' ' ) ; 23 24 25 26 27 28 29 else contro!Flag false; while (controlFlag)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What magnitudes of current may be used to produce resistance welds?

Answered: 1 week ago