hey- programming help! (I have most of it)

These are my instructions: (I do realize that this has been posted on this site before but my teacher did add additional parts onto the original project and that is what I am having issues with- thanks!)

Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows.

1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don't display the computer's choice yet.)
2. The user enters his or her choice of "rock", "paper", or "scissors" at the keyboard. (You can use a menu if you prefer.)
3. The computer's choice is displayed.
4. A winner is selected and displayed according to the following rules:

If one player chooses rock and the other player chooses scissors, then rock wins. (The rock smashes the scissors.)
If one player chooses scissors and the other player chooses paper, then scissors wins. (The scissors cuts paper.)
If one player chooses paper and the other player chooses rock, then paper wins. (Paper wraps rock.)
If both players make the same choice, the game must be played again to determine the winner

Be sure to divide the program into functions that perform each major task.
Make sure to allow the user to play the game over and over if he wishes.

My teacher's additional instructions:

Make sure to have one function displaying the menu (scissors, paper, or rock), reading the choice, validating it and rereading if needed, and then returning the valid choice as a number 1-3.
Make sure to have another function to which you send what the user selected and what computer generated, and the function will declare the winner printing the result.
Make sure to use srand()
Put a loop for the program to keep working on multiple games until the user enters a quit choice on the menu (the same menu where the choice is entered).


Here is my code:

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>

using namespace std;

void first(){
string userchoice;
int compchoice = (rand()%2)+1;
int user;

cout << "Your options: " << endl << " Rock" << endl << " Paper" << endl << " Scissors" << endl << "Your choice: ";

cin >> userchoice;

while(true){

if (userchoice == "rock" || userchoice == "Rock")
user = 1;
else if (userchoice == "paper" || userchoice == "Paper")
user = 2;
else if (userchoice == "scissors" || userchoice == "Scissors")
user = 3;
else if (userchoice == "exit" || userchoice == "Exit")
exit(0);
else {
cout << userchoice << " is not a valid choice. Please type an option from the menu above: ";
cin >> userchoice;
}
}
}

int second(string userchoice && int compchoice){

cout << endl << "Computer's choice: ";

if (user == 1){
if (compchoice == 1)
cout << "Rock" << endl << "Tie! Good try!" << endl;
else if (compchoice == 2)
cout << "Paper" << endl << "Paper beats rock! You lose! :(" << endl;
else if (compchoice == 3)
cout << "Scissors" << endl << "Rock beats scissors! You win! :)" << endl;
cout << endl << endl;
}

if (user == 2){
if (compchoice == 1)
cout << "Rock" << endl << "Paper beats rock! You win! :)" << endl;
else if (compchoice == 2)
cout << "Paper" << endl << "Tie! Good try!" << endl;
else if (compchoice == 3)
cout << "Scissors" << endl << "Rock beats scissors! You lose! :(" << endl;
cout << endl << endl;
}

if (user == 3){
if (compchoice == 1)
cout << "Rock" << endl << "Rock beats scissors! You lose! :(" << endl;
if (compchoice == 2)
cout << "Paper" << endl << "Scissors beat paper! You win! :)" << endl;
if (compchoice == 3)
cout << "Scissors" << endl << "Tie! Good try!" << endl;
cout << endl << endl;
}
}


int main(){

srand((unsigned)time(0));
cout << "Let's play Rock, Paper, Scissors!" << endl << endl;

first();


int second(string userchoice && int compchoice);

return 0;

}


My compiler errors: (i dont seem to know how to pass the comp choice and user variables)

project5.cpp:34: error: expected `,' or `...' before '&&' token
project5.cpp: In function `int second(std::string)':
project5.cpp:38: error: `user' was not declared in this scope
project5.cpp:39: error: `compchoice' was not declared in this scope
project5.cpp:48: error: `user' was not declared in this scope
project5.cpp:49: error: `compchoice' was not declared in this scope
project5.cpp:58: error: `user' was not declared in this scope
project5.cpp:59: error: `compchoice' was not declared in this scope
project5.cpp:61: error: `compchoice' was not declared in this scope
project5.cpp:63: error: `compchoice' was not declared in this scope
project5.cpp: In function `int main()':
project5.cpp:77: error: expected `,' or `...' before '&&' token

Topic archived. No new replies allowed.