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

Restate the problem, and specifiy what input is needed from whomever is using th

ID: 3666642 • Letter: R

Question

Restate the problem, and specifiy what input is needed from whomever is using the process, what output is expected, the step by step process (algorithm) to get the output from the input, and test data (input for which you know the expected output). No actual code needs to be written.

Develop a process that will allow you to simulate a lottery. A 2-digit random number (numbers zero – 99) should be generated. The user should be prompted to enter a positive number less than hundred (for now assume that a valid number is entered). If the user’s number matches randomly generated number exactly, the user wins $5000.00. If the users guess contains the same digits as the randomly generated number, but they are in reverse order (e.g. 67 and 76), the user will win $2000.00. If one digit of the user’s guess is in the randomly generated number, the user should win $500.00. If the randomly generated number or the user’s guess is less than 10 treat the number as if it has 0 as the first digit (9 should be treated as 09).

For example, suppose the randomly generated number was 78. The user would win $5000 if he/she had guessed 78, $2000 if he/she had guessed 87, or $500.00 if his/her guess contained a 7 or 8.

Explanation / Answer

lottery(){
     
   int random ; // randomly generate a number between[0-99]
   int userInput; // take a input from user between[0-99]
   printf("Enter a number [0-99]");
   userInput <- userinput
   int lotteryAmount = 0;// initializa lottery amount
     
   if(random == userInput)
       lotteryAmount = $5000.00
   int reverUserInput = reverse(userInput); // reverse userinput
   if(reverUserInput == random)
       lotteryAmount = $2000.00
   // checking any of digits from userinput present in random number
   while(userInput > 0) {
       int userDigit = userInput % 10;// getting one digit from right(last)
       userInput /=10;// removing processed digitt from userInpu
      
       while(random > 0) { //for all digit from random
           int randomDigit = random%10;
           random /=10;
          
           if(userDigit == randomDigit) // if there a match
               lotteryAmount = $500.00
           }
       }
   return lotteryAmount;

}

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