Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

When compiling c++ code I find these errors, please help me correct: Errors: lab

ID: 3790531 • Letter: W

Question

When compiling c++ code I find these errors, please help me correct:

Errors:

lab05.cpp: In function ‘int main()’:
lab05.cpp:10:2: error: ‘String’ was not declared in this scope
String playerOption;
^
lab05.cpp:13:9: error: ‘playerOption’ was not declared in this scope
cin >> playerOption;
^
lab05.cpp:17:14: error: ‘Null’ was not declared in this scope
srand (time (Null));
^
lab05.cpp:18:8: error: assignment of function ‘int system(const char*)’
system = rand () %10 +1;
^
lab05.cpp:18:8: error: cannot convert ‘int’ to ‘int(const char*)’ in assignment
lab05.cpp:19:13: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
if(system <=3)
^
lab05.cpp:26:19: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
else if (system <=6)
^
lab05.cpp:32:19: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
else if (system >=7)
^
lab05.cpp:38:37: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
if(playerOption = "rock" &&system <=3)
^
lab05.cpp:45:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
else if(playerOption == "rock" &&system <=6)
^
lab05.cpp:52:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
else if(playerOption == "rock" &&system >=7)
^
lab05.cpp:59:38: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
if(playerOption = "paper" &&system <=3)
^
lab05.cpp:66:44: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
else if(playerOption == "paper" &&system <=6)
^
lab05.cpp:73:44: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
else if(playerOption == "paper" &&system >=7)
^
lab05.cpp:80:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
if(playerOption = "scissors" &&system <=3)
^
lab05.cpp:87:47: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
else if(playerOption == "scissors" &&system <=6)
^
lab05.cpp:94:47: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
else if(playerOption == "scissors" &&system >=7)
^

ORIGINAL CODE:

#include<iostream>
#include<stdlib.h>
#include<time.h>

using namespace std;

int main()
{
   do {
   String playerOption;
  
   cout << "Ready to play Rock, Paper or Scissors game?" <<endl;
   cin >> playerOption;
   cout << "Enter your entry:" << playerOption << endl;  
      
cout << " " << endl;
srand (time (Null));      
system = rand () %10 +1;
if(system <=3)
  
{
   cout << "System entry is Rock" << endl;
   cout << " " <<endl;
}

else if (system <=6)
{
   cout << "System entry is Paper" << endl;
   cout << " " << endl;
}

else if (system >=7)
{
   cout << "System entry is Scissors" << endl;
   cout << " " << endl;
   }
  
if(playerOption = "rock" &&system <=3)
  
{
   cout << "Tie game" << endl;
   cout << " " << endl;
}

else if(playerOption == "rock" &&system <=6)
  
{
   cout << "You lost the game" << endl;
   cout << " " << endl;
}

else if(playerOption == "rock" &&system >=7)

{
   cout << "Won the game" << endl;
   cout << " " << endl;
}

if(playerOption = "paper" &&system <=3)
  
{
   cout << "You won the game" << endl;
   cout << " " << endl;
}

else if(playerOption == "paper" &&system <=6)
  
{
   cout << "Game is a tie" << endl;
   cout << " " << endl;
}

else if(playerOption == "paper" &&system >=7)

{
   cout << "You lost the game" << endl;
   cout << " " << endl;
}

if(playerOption = "scissors" &&system <=3)
  
{
   cout << "You lost the game" << endl;
   cout << " " << endl;
}

else if(playerOption == "scissors" &&system <=6)
  
{
   cout << "You won the game" << endl;
   cout << " " << endl;
}

else if(playerOption == "scissors" &&system >=7)

{
   cout << "Tie game" << endl;
   cout << " " << endl;
}

} while(cin.get());

   cin.get();
  

return 0;
}

Explanation / Answer

include these in first line:

you need to declare system variable

by using below statement

float system;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote