Programming Project
Programming Project
By:
Momen Nazar Salim
Musa Thamer muhammed
Hadeel Amer Salih
Yassmin Haider Abid Al-ilah
Wael Ahmed Saady
Malak Khalid Nassif
Noor Al-huda Ali Noori
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{ srand(time(NULL));
int user = 0;
Int computer = 0;
cout << "Stone Paper Scissor Game" << endl;
cout << "1) Rock" << endl;
cout << "2) Paper" << endl;
cout << "3) Scissor" << endl;
cin >> user;
if(user == 1)
{cout << "You choose Rock" << endl; }
else if(user == 2)
{cout << "You choose Paper" << endl; }
else
{cout << "You choose Scissor" << endl; }
computer = rand()%3+1;
if(computer == 1)
{cout << "Computer chooses Rock" << endl;
else if(computer == 2)
{ cout << "Computer chooses Paper"<< endl; }
else{ cout << "Computer chooses Scissor" << endl; }
// match
if(user == computer)
{ cout << "Match Tie" << endl; }
// user --> Rock
else if(user == 1)
{ if(computer == 2)
{ cout << "You lose!" << endl; }
if(computer == 3)
{ cout << "You win!" << endl; } }
// user --> Paper
else if(user == 2)
{ if(computer == 1)
{ cout << "You win!" << endl; }
if(computer == 3)
{ cout << "You lose!" << endl; } }
// user --> Scissor else if(user == 3)
{ if(computer == 1)
{ cout << "You lose!" << endl; }
if(computer == 2){ cout << "You win!" << endl; } } return 0;}
• The program focuses on using loops wich in this case its a loop inside
another loop to make a good use out of (if,else).
• If you choose rock and the computer chooses paper the program will
print you lose and if its the opposite you win.
• If you choose scissor and the computer chooses paper the program
will print you win and if its the opposite you lose.
• If you choose rock and the computer chooses scissor the program will
print you win and if its the opposite you lose.