Please proved the whole typed C++ code(not photo, can run correctly in visiual s
ID: 3886687 • Letter: P
Question
Please proved the whole typed C++ code(not photo, can run correctly in visiual studio) following the Requirements blew, thank you very much.
"Requirements for Project 2:
Project is called NUMBER GAME
1. Figure out how to output a random number using the RAND() with the equation. ( You can Google that)
2. Secondly ask the user to Enter a Number.
3. The player will have either 5 or 10 attempts to guess the lucky Random Number. **Please make sure the Random number is from either 0 to 20 or 0 to 50**
4. If the user guesses the correct number output a MESSAGE break out of the loop.
5. If the user guesses the wrong number while within the attempts OUTPUT a message from step #2.
6. If the user have exhaust all of the attempts OUTPUT a message "You Lose Go Home"(Use your creativity of what message to output.)
Loop required to have:
1. If/else statements
2. Either a Do/while, while or For loop
Also, including blew in the code:
1. Give the user a certain amount of seconds to guess the number correctly.
2. Post an "ERROR MESSAGE" if the user enter characters instead of values."
Explanation / Answer
#include<iostream>
#include<cstdlib>
using namespace std;
main()
{
int n, num, count=0;
do
{
cout << "Enter the number of random numbers you want between 1-50 ";
cin >> n;
num = random()%50;
if(n==num)
{
cout<<" You Win the Game";
}
count++;
if(count==5)
{
cout<<" You have reached maximum limits Thank You";
break;
}
}while(n!=num);
return 0;
}
Output:
Enter the number of random numbers you want between 1-50
33
You Win the Game
Output2:
Enter the number of random numbers you want between 1-50 27
Enter the number of random numbers you want between 1-50 33
Enter the number of random numbers you want between 1-50 67
Enter the number of random numbers you want between 1-50 87
Enter the number of random numbers you want between 1-50 55
You have reached maximun limits Thank You
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.