0

Project (Help on while loop)

Hello, for this program two students must enter a symbol to generate a random math problem, however, i have attempted to input to where if both students got it correct, itll output theyre both correct and the program will start over, I also want this to apply if they both got the math problem incorrect but when I enter two correct answers or two incorrect answers itll input both player 1 and player 2 getting the win or point, how can i make it so that itll ONLY output if both are correct when both get the right answer as well as how to output so it ONLY says theyre incorrect if both answers given are wrong? // Created by Gabriel Reyes //C++ Program FINAL PROJECT //Gabriel Reyes, February 5, 2022 CIS-5 #include <iostream> #include <cmath> #include <ctime> //v1.2 using namespace std; int main() { char programerChoice = 'y'; do { srand(time(NULL)); //v1.2 char sym_choice; //Symbol Choice int one, two; int user_1; int user_2; cout << "\tHello, please Select A symbol to\n"; cout << "\tsolve a random math problem: \n"; cout << "\t(+,-,*,)\n\n"; cout << "\tENTER YOUR CHOICE: "; cin >> sym_choice; // bool int answer = 0; bool CORRECT = false; if (CORRECT == answer) { CORRECT = true; } one = rand() % 500 + 1; two = rand() % 500 + 1; std::cout << "What is " << one << " " << sym_choice << " " << two << "? "; cout << "Player 1: "; cin >> user_1; cout << "Player 2: "; cin >> user_2; switch (sym_choice) { case '+': answer = one + two; if (user_1 == answer || user_2 != answer) cout << "Player 1 is Correct, Try again Player 2!"; if (user_1 != answer || user_2 == answer) cout << "Player 2 is Correct, Try again Player 1!"; else if (user_1 && user_2 == answer) cout << "Both are correct, select another symbol to start over! "; else if (user_1 && user_2 != answer) cout << "Both are INCORRECT, please start over!"; CORRECT = true; break; case '-': answer =

9th Feb 2022, 4:23 PM
Gabriel Reyes
2 odpowiedzi
0
Please look at case (+) for example, I will apply that to (-) and (*)
9th Feb 2022, 4:23 PM
Gabriel Reyes
0
I FIXED IT
9th Feb 2022, 4:31 PM
Gabriel Reyes