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

Which changes would be necessary in the Rich Uncle program if uppercase letters

ID: 3778575 • Letter: W

Question

Which changes would be necessary in the Rich Uncle program if uppercase letters and lowercase letters were to be counted as members of the same category? Write a number-guessing game in which computer selects a random number in the range of 1 to 100. and users get a maximum of 20 attempts to guess it. At the end of each game, user should be told weather they won or lost, and then be asked whether they want to play again. When the user quits, the program should output the total number of wins and losses. To make game more interesting, the program should vary the wording of the messages that it outputs for winning, for losing, and for asking for another game. Create as many as 10 different messages for each of these cases, and use random numbers to choose among them. See Appendix C.7 for information on the C++ random-number generator functions. This application should provide a good opportunity for you to use a do-while statement and switch statements. Use functional decomposition to solve the problem. Write your C++ code using good style and documenting comments, and have fun thinking up some messages that will surprise the user.

Explanation / Answer

2)

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

static const char Win_quote[] =
"Awesome!!!"
"Keep it uppp"
"Wowww!!! U did itt"
"heyyy!! give me partyyy";

int strLength = sizeof(Win_quote) - 1;

char genRandom() // Random string generator function.
{

return Win_quote[rand() % strLength];
}

int rand_num() //Random number generator b/w 1 and 100
{
   return (rand()%100)+1;
}

using namespace std;
int main()
{  
   srand((unsigned)time(0));
   int guess,attempt=20,wincount=0,lostcount=0,num;  
   char ch;
   do
   {
   num=rand_num();
       do
       {
       cout<<"guess the number between 1 and 100"<<" ";
       cin>>guess;
           if(guess==num)
           {
           cout<<genRandom();
           wincount++;
          
           }
       }while(guess!=num&&attempt>0);
   if(attempt==0)
   {
       cout<<"You lose the GAME"<<" ";
       lostcount++;
   }
   cout<<"Do you wanna play again[PRESS Y/N]"<<" ";
   cin>>ch;
  
}while(ch=='Y'||ch=='y');


   cout<<"Total wins = "<<wincount;
   cout<<"total losts = "<<lostcount;      
}

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