/* Haso Keric CO127 (SATURDAY) MID-TERM */ #include #include // Used for getch using namespace std; // Introduce functions so the program knows they exists void Welcome(void); void AskForName(void); void PressAnyKey(void); void GetResults(void); // Global Variables, so they can be accessed from any Function char name[55]; int totalvotes = 0; int Dorito1[4] = {0,0,0,0}; int Dorito2[4] = {0,0,0,0}; int Dorito3[4] = {0,0,0,0}; int Dorito4[4] = {0,0,0,0}; int Dorito5[4] = {0,0,0,0}; int main() { Welcome(); // Call the Welcome Function AskForName(); // A function to ask for the name of the person rating our product system("CLS"); // Clear the Screen /* List the Doritos, i know it could have been done also by storing the names within an Array and calling them, but i realized that 2 hours later so i did not make any changes */ cout << " DORITO RATING (NEWEST 5 PRODUCTS) -> -> Welcome, " << name << "\n"; cout << "\n"; cout << " \t1. SUPER HOT NACHO\n"; cout << " \t2. CHEESY CHEESE\n"; cout << " \t3. CRAZY TACO\n"; cout << " \t4. CHICKEN FIESTA\n"; cout << " \t5. LOWFAT\n"; int dorito = 0; // Store the Doritos Number int question = 0; // Initialize question int, which is used in the case totalvotes++; // Add +1 to the totalvotes againx: // A Goto Statement cout << "\n\t Vote for your favorite Doritos: "; // Question cin >> dorito; // Store Character in dorito (the int we initialized earlier) // CIN Error Handling if (cin.fail()) { cin.clear(); char error; cin >> error; goto againx; // If Failed try again (goto the GOTO Statement) } switch (dorito) { cout << "\n\t [1 Being the Lowest, 5 Being the Highest]"; // Info case 1: Dorito1[0]++; // ADD +1 to the Dorito Array tryagain1: // Goto Statement for the if/elses cout << "\n\t !Question! What is the overall TASTE: "; cin >> question; if (cin.fail()) // Error Handling { cin.clear(); char error; cin >> error; goto tryagain1; // Go back to the Goto } if (question < 1 || question > 5) { cout << "\n\t >> You must be above 0 and below 5"; goto tryagain1; } Dorito1[1] = Dorito1[1] + question; tryagain2: cout << "\n\t !Question! What is the overall COLOR: "; cin >> question; if (cin.fail()) { cin.clear(); char error; cin >> error; goto tryagain2; } if (question < 1 || question > 5) { cout << "\n\t >> You must be above 0 and below 5"; goto tryagain2; } Dorito1[2] = Dorito1[2] + question; tryagain3: cout << "\n\t !Question! What is the overall SMELL: "; cin >> question; if (cin.fail()) { cin.clear(); char error; cin >> error; goto tryagain3; } if (question < 1 || question > 5) { cout << "\n\t >> You must be above 0 and below 5"; goto tryagain3; } Dorito1[3] = Dorito1[3] + question; break; case 2: Dorito2[0]++; tryagain4: cout << "\n\t !Question! What is the overall TASTE: "; cin >> question; if (cin.fail()) { cin.clear(); char error; cin >> error; goto tryagain4; } if (question < 1 || question > 5) { cout << "\n\t >> You must be above 0 and below 5"; goto tryagain4; } Dorito2[1] = Dorito2[1] + question; tryagain5: cout << "\n\t !Question! What is the overall COLOR: "; cin >> question; if (cin.fail()) { cin.clear(); char error; cin >> error; goto tryagain5; } if (question < 1 || question > 5) { cout << "\n\t >> You must be above 0 and below 5"; goto tryagain5; } Dorito2[2] = Dorito2[2] + question; tryagain6: cout << "\n\t !Question! What is the overall SMELL: "; cin >> question; if (cin.fail()) { cin.clear(); char error; cin >> error; goto tryagain6; } if (question < 1 || question > 5) { cout << "\n\t >> You must be above 0 and below 5"; goto tryagain6; } Dorito2[3] = Dorito2[3] + question; break; case 3: Dorito3[0]++; tryagain7: if (cin.fail()) { cin.clear(); char error; cin >> error; goto tryagain7; } cout << "\n\t !Question! What is the overall TASTE: "; cin >> question; if (question < 1 || question > 5) { cout << "\n\t >> You must be above 0 and below 5"; goto tryagain7; } Dorito3[1] = Dorito3[1] + question; tryagain8: if (cin.fail()) { cin.clear(); char error; cin >> error; goto tryagain8; } cout << "\n\t !Question! What is the overall COLOR: "; cin >> question; if (question < 1 || question > 5) { cout << "\n\t >> You must be above 0 and below 5"; goto tryagain8; } Dorito3[2] = Dorito3[2] + question; tryagain9: cout << "\n\t !Question! What is the overall SMELL: "; cin >> question; if (cin.fail()) { cin.clear(); char error; cin >> error; goto tryagain9; } if (question < 1 || question > 5) { cout << "\n\t >> You must be above 0 and below 5"; goto tryagain9; } Dorito3[3] = Dorito3[3] + question; break; case 4: Dorito4[0]++; tryagain10: cout << "\n\t !Question! What is the overall TASTE: "; cin >> question; if (cin.fail()) { cin.clear(); char error; cin >> error; goto tryagain10; } if (question < 1 || question > 5) { cout << "\n\t >> You must be above 0 and below 5"; goto tryagain10; } Dorito4[1] = Dorito4[1] + question; tryagain11: cout << "\n\t !Question! What is the overall COLOR: "; cin >> question; if (cin.fail()) { cin.clear(); char error; cin >> error; goto tryagain11; } if (question < 1 || question > 5) { cout << "\n\t >> You must be above 0 and below 5"; goto tryagain11; } Dorito4[2] = Dorito4[2] + question; tryagain12: cout << "\n\t !Question! What is the overall SMELL: "; cin >> question; if (cin.fail()) { cin.clear(); char error; cin >> error; goto tryagain12; } if (question < 1 || question > 5) { cout << "\n\t >> You must be above 0 and below 5"; goto tryagain12; } Dorito4[3] = Dorito4[3] + question; break; case 5: Dorito5[0]++; tryagain13: cout << "\n\t !Question! What is the overall TASTE: "; cin >> question; if (cin.fail()) { cin.clear(); char error; cin >> error; goto tryagain13; } if (question < 1 || question > 5) { cout << "\n\t >> You must be above 0 and below 5"; goto tryagain13; } Dorito5[1] = Dorito5[1] + question; tryagain14: cout << "\n\t !Question! What is the overall COLOR: "; cin >> question; if (cin.fail()) { cin.clear(); char error; cin >> error; goto tryagain14; } if (question < 1 || question > 5) { cout << "\n\t >> You must be above 0 and below 5"; goto tryagain14; } Dorito5[2] = Dorito5[2] + question; tryagain15: cout << "\n\t !Question! What is the overall SMELL: "; cin >> question; if (cin.fail()) { cin.clear(); char error; cin >> error; goto tryagain15; } if (question < 1 || question > 5) { cout << "\n\t >> You must be above 0 and below 5"; goto tryagain15; } Dorito5[3] = Dorito5[3] + question; break; default: goto againx; break; } // The Above is just the Cases they all are the same. int newfriend = 0; // Initialize friendagain: cout << "\n Now " << name << " Want to Rate Again? (1 for yes, 0 for no): "; cin >> newfriend; if (cin.fail()) { cin.clear(); char error; cin >> error; goto friendagain; } // IF A NEW FRIEND WANTS TO VOTE Go back to the Voting else Go to the Results if (newfriend == 1) { totalvotes++; goto againx; } if (newfriend == 0) { GetResults(); } return 0; // End the Program } void GetResults(void) { //Results system("CLS"); cout << "-> SUPER 5 DORITOS (RESULTS)\n\n"; cout << "\tTotal Votes: " << totalvotes << "\n\n\t People Voted For:\n"; if (Dorito1[0] != NULL) { cout << "\t\tSuper Hot Nacho\n"; cout << "\t\tTaste " << Dorito1[0] << "\n"; cout << "\t\tColor " << Dorito1[1] << "\n"; cout << "\t\tSmell " << Dorito1[2] << "\n\n"; } if (Dorito2[0] != NULL) { cout << "\t\tCheesy Cheese\n"; cout << "\t\tTaste " << Dorito2[0] << "\n"; cout << "\t\tColor " << Dorito2[1] << "\n"; cout << "\t\tSmell " << Dorito2[2] << "\n\n"; } if (Dorito3[0] != NULL) { cout << "\t\tCrazy Taco\n"; cout << "\t\tTaste " << Dorito3[0] << "\n"; cout << "\t\tColor " << Dorito3[1] << "\n"; cout << "\t\tSmell " << Dorito3[2] << "\n\n"; } if (Dorito4[0] != NULL) { cout << "\t\tChicken Feista\n"; cout << "\t\tTaste " << Dorito4[0] << "\n"; cout << "\t\tColor " << Dorito4[1] << "\n"; cout << "\t\tSmell " << Dorito4[2] << "\n\n"; } if (Dorito5[0] != NULL) { cout << "\t\tLow Fat\n"; cout << "\t\tTaste " << Dorito5[0] << "\n"; cout << "\t\tColor " << Dorito5[1] << "\n"; cout << "\t\tSmell " << Dorito5[2] << "\n\n"; } cout << "\n\n\t No one voted for:\n"; if (Dorito1[0] == NULL) cout << "\t\tSuper Hot Nacho\n"; if (Dorito2[0] == NULL) cout << "\t\tCheesy Cheese\n"; if (Dorito3[0] == NULL) cout << "\t\tCrazy Taco\n"; if (Dorito4[0] == NULL) cout << "\t\tChicken Feista\n"; if (Dorito5[0] == NULL) cout << "\t\tLow Fat\n"; cout << "Thank You!\n"; system("pause"); } void Welcome(void) { system("Color 02"); // Change the Color to Green with Black Background cout << "\n\n -> Welcome to the "; cout << "Dorito Survey \n"; cout << " -> Please take a few moments to grade our delicious latest Dorito product.\n\n"; // Welcome Msg PressAnyKey(); system("CLS"); } void AskForName(void) { system("Color F2"); cout << " What is your Full Name: "; cin.getline(name,55); } void PressAnyKey(void) { cout << "Press any key to continue IF YOU LOVE Doritos........."; getch(); }