Details of this Paper

Begginner's C++, modify this magic number program with for and while loops.

Description

solution


Question

Modify the magic number program so that the user can guess at more than one magic number where the magic number is an integer between 1 and 20. When the program is run, the user should be prompted with the number of magic numbers that they would like to guess at. An additional loop is necessary for this capability, and the loop to be implemented must be a for loop. The user should be given 5 guesses for each number and be responded with a clue after each guess on whether the guess is too high or low. The program should also make sure that if the user enters an invalid guess at the magic number (less than 1 or greater than 20), then the user should be prompted with an invalid guess message and not be penalized for a guess attempt. A while loop must be implemented for this part of the program. before the program is completed, the user should be notified of their success rate given by the following formula;# of magic numbers guess correctly/ # of magic numbers attempted x 100 A magic number is counted as guessed correctly if the user guesses the magic number correctly within 5 guesses. *** Here is the program. You can modify it to do the above for loop and such. I also put it in a word document. #include;#include;#include;#include;using namespace std;int main();srand(static_cast (time(0)));int randomNumber = rand() % 20 + 1;int tries = 0;int guess;do;cout < > guess;++tries;if (guess > randomNumber);cout << "too high!\n;else if (guess < randomNumber);cout << " too low!\n;else;cout << "You won! " << tries < =5);cout << "You have failed. \n;break;while (guess != randomNumber);system("pause");return 0

 

Paper#71494 | Written in 18-Jul-2015

Price : $22
SiteLock