Concept explainers
Write the magic number program in C++ 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 if they would like to guess at a magic number and continue to be prompted as such after they have guessed a magic number correctly. A while loop is necessary for this capability, The user should be given as many guesses as necessary for each number until they guess the number correctly.
A do-while loop must be implemented for this part of the program. They should also 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. After the user guesses the number correctly, they should be graded on their effort. If they guess the number correctly within 3 guesses, rate them as "Excellent". If they guess the number correctly within 5 guesses, rate them as "Good". If they guess the number correctly within 7 guesses, rate them as "Average". If they guess the number correctly with more than 7 guesses, rate them as "Poor". Use either an if-else-if ladder or a switch block to rate the user.
Step by stepSolved in 3 steps with 1 images
- code must be done in C++ no other language is acceptableWrite a program using nested loops that asks the user to enter a value for the number of rows to display. It should then display that many rows of * and $, with one * in the first row, two in the second row, and so on. However, the last in each row should be aligned (preceded by as many $ as necessary). A sample run would look like this: Enter number of rows: 5 Then the and $ should appear like this: * $ $ $ $ $ $ $ * * * $ $ $ * * *arrow_forwardIn C++arrow_forwardIn this lab, you use a counter-controlled while loop in a C++ program provided for you. When completed, the program should print the numbers 0 through 10, along with their values multiplied by 2 and by 10. The data file contains the necessary variable declarations and some output statements. Instructions Ensure the source code file named Multiply.cpp is open in the code editor. Write a counter-controlled while loop that uses the loop control variable to take on the values 0 through 10. Remember to initialize the loop control variable before the program enters the loop. In the body of the loop, multiply the value of the loop control variable by 2 and by 10. Remember to change the value of the loop control variable in the body of the loop. Execute the program by clicking the Run button. Record the output of this program. **CODE GIVEN** // Multiply.cpp - This program prints the numbers 0 through 10 along // with these values multiplied by 2 and by 10. // Input: None // Output:…arrow_forward
- program must include a processing loop that allows multiple sets of data to be processed and the program should be terminated when there is no more data to process Develop a program in python that allows the user to enter a start value of 1 to 4, a stop value of 5 to 12 and a multiplier of 2 to 8. The program must display a multiplication table with results using these values. For example, if the user enters a start value of 3, a stop value of 7 and a multiplier value of 3, the table should be displayed as follows: Multiplication Table 3 x 3 = 9 3 x 4 = 12 3 x 5 = 15 3 x 6 = 18 3 x 7 = 21 Run the program with the following values: Start Stop Multiplier 2 10 4 4 12 6arrow_forwardDrawa structured flowchart , C++, write pseudocode that describes the process of guessing a number between 1 and 100. After each guess, the player is told that the guess is too high or too low. The process continues until the player guesses the correct number. Pick a number and have a fellow student try to guess it following your instructions.arrow_forwardThis program in C++ obtains a series of letter grades as input from a user. The program should calculate and output the total grade points and the grade point average (note: you may have to track the total number of inputs and the grade points to calculate the grade point average). The algorithm should execute 3 times for testing purposes.Use the appropriate loop for the main structure of the program that will stop accepting letter grades when the user inputs X. Also, choose the appropriate selection statement to convert the letter grade to the correct grade points.Additional Requirements:• Use appropriate data types and variable names throughout the code.• Use constants appropriately. Output needs to look like the image below.arrow_forward
- make a C program that implements the "guess my number" game. The computer chooses a random number using the following random generator function srand(time(NULL)); int r = rand() % 100 + 1; that creates a random number between 1 and 100 and puts it in the variable r. (Note that you have to include <time.h>) Then it asks the user to make a guess. Each time the user makes a guess, the program tells the user if the entered number is larger or smaller than its number. The user then keeps guessing till he/she finds the number. If the user doesn't find the number after 10 guesses, a proper game over message will be shown and the actual guess is revealed. If the user makes a correct guess in its allowed 10 guesses, then a proper message will be shown and the number of guesses the user made to get the correct answer is also printed. After each correct guess or game over, the user decides to play again or quit and based on the user choice, the computer will make another guess and…arrow_forwardIn this lab, you use a counter-controlled while loop in a C++ program provided for you. When completed, the program should print the numbers 0 through 10, along with their values multiplied by 2 and by 10. The data file contains the necessary variable declarations and some output statements. Instructions Ensure the source code file named Multiply.cpp is open in the code editor. Write a counter-controlled while loop that uses the loop control variable to take on the values 0 through 10. Remember to initialize the loop control variable before the program enters the loop. In the body of the loop, multiply the value of the loop control variable by 2 and by 10. Remember to change the value of the loop control variable in the body of the loop. Execute the program by clicking the Run button. Record the output of this program. **CODE GIVEN** // Multiply.cpp - This program prints the numbers 0 through 10 along // with these values multiplied by 2 and by 10. // Input: None // Output:…arrow_forwardUsing a Sentinel Value to Control a while Loop in C++ In this lab, you write a while loop that uses a sentinel value to control a loop in a C++ program that has been provided. You also write the statements that make up the body of the loop. The source code file already contains the necessary variable declarations and output statements. Each theater patron enters a value from 0 to 4 indicating the number of stars the patron awards to the Guide’s featured movie of the week. The program executes continuously until the theater manager enters a negative number to quit. At the end of the program, you should display the average star rating for the movie. Instructions Ensure the source code file named MovieGuide.cpp is open in your code editor. Write the while loop using a sentinel value to control the loop, and write the statements that make up the body of the loop. The output statements within the loop have already been written for you. Ensure you include the calculations to compute the…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education