Link to Project: https://www.codecademy.com/courses/learn-c-plus-plus/projects/rock-paper-scissors-lizard-spock
I am honestly not sure what exactly to do. When I compile the code using the g++ command I always get this error from it (Error: expected unqualified-id before ‘if’/‘else’). I looked it up on Google and apparently, it is an issue with the syntax of the code which and not exactly sure where. I was hoping someone could point out what I did wrong in the code and help me with it.
Code:
include <iostream>
#include <stdlib.h>
/* Rock Paper Scissors Lizard Spock
(The Big Bang Theory)
*/
int main() {
// Live long and prosper
srand (time(NULL));
int computer = rand() % 3 + 1;
int user = 0;
std::cout << "====================\n";
std::cout << "rock paper scissors!\n";
std::cout << "====================\n";
std::cout << "1) ✊\n";
std::cout << "2) ✋\n";
std::cout << "3) ✌️\n";
std::cout << "shoot! ";
std::cin >> user;
}
if (user == 1) {
std::cout << "You choose: ✊\n";
}
else if (user == 2) {
std::cout << "You choose: ✋\n";
}
else if {
std::cout << "You choose: ✌️\n";
}
if (computer == 1) {
std::cout << "The Computer choose: ✊\n";
}
else if (computer == 2) {
std::cout << "The Computer choose: ✋\n";
}
else if {
std::cout << "The Computer choose: ✌️\n";
}
if (user == computer) {
std::cout << "it's a tie!\n";
}
// user rock
else if (user == 1) {
if (computer == 2) {
std::cout << "The Computer won!\n";
}
if (computer == 3) {
std::cout << "You won!\n";
}
}
// user paper
else if (user == 2) {
if (computer == 1) {
std::cout << "You won!\n";
}
if (computer == 3) {
std::cout << "The Computer won!\n";
}
}
// user scissors
else if (user == 3) {
if (computer == 1) {
std::cout << "You won!\n";
}
if (computer == 2) {
std::cout << "The Computer won!\n";
}
}