Hey everyone I am New here.... need some help with my coding for my college HW assignment.... I need to make a rock paper scissor game. I can think of the game in my brain on how I am gona code it but when I try to program it doesnt work.... here is some bit of my code.
I am playing against the computer and this is the beginning. my main question is on the loop and the randomness. I need the program to keep going and show score after every 3 times and the user can quit the game when ever they want by typing X instead of the number to select.
#include <iostream>
#include <cstdlib>
#include <string>
#include <ctime>
using namespace std;
int main()
{
bool keepPlaying = true;
string Name;
char replay;
int cpuSele, playerSele, gamePlayed, win, lose;
gamePlayed = 0;
win = 0;
lose = 0;
cout << "Please Enter your name: ";
cin >> Name;
cout << "\nWelcome " << Name << endl;
srand(time(0));
cpuSele = 1 + rand() % 3;
cout << "Select one of the following with number: " << endl;
cout << "1 = Rock" << endl;
cout << "2 = Paper" << endl;
cout << "3 = Scissor" << endl;
cin >> playerSele;
while(keepPlaying) //trying to loop here :S
switch(cpuSele)
case 1:
if(playerSele == 1)
cout << "Rock <===> Rock" << endl;
cout << "TIE, try again" << endl;
gamePlayed++;
cout << "Games Played: " << gamePlayed << endl;
//game should keep playing as long as it can go
//shows the score after every 3 games.
//user can quit anytime by pressing X || x
system("pause");
return 0;
}