Question

Create a new console application (using the .NET Framework and not .NET Core). Name your project...

Create a new console application (using the .NET Framework and not .NET Core). Name your project and solution RandomGuess. Generate a random number between 1 and 100, using the Random (Links to an external site.) class. Prompt the user to guess the random number until they successfully guess it.

Extra's:

  • Allow the user to input the range for the random number (between X and Y)
  • Validate that the user actually input a valid number, if they did not, prompt them to input a valid number
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

using System;
                  
public class Program
{
   public static void Main()
   {
       Random r = new Random();
       int randomNum = r.Next(1, 100);
       Console.WriteLine("Enter your guess between 1 and 100: ");
       int userGuess = Convert.ToInt32(Console.ReadLine());
       while(userGuess!=randomNum)
       {
           Console.WriteLine("Sorry! Invalid guess. Please enter a valid guess between 1 and 100: ");
           userGuess = Convert.ToInt32(Console.ReadLine());
           if(userGuess==randomNum)
           {
               Console.WriteLine("Congrats!!! you guessed right");
               break;
           }
       }
   }
}

Output:

Add a comment
Know the answer?
Add Answer to:
Create a new console application (using the .NET Framework and not .NET Core). Name your project...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • create java application with the following specifications: -create an employee class with the following attibutes: name...

    create java application with the following specifications: -create an employee class with the following attibutes: name and salary -add constuctor with arguments to initialize the attributes to valid values -write corresponding get and set methods for the attributes -add a method in Employee called verify() that returns true/false and validates that the salary falls in range1,000.00-99,999.99 Add a test application class to allow the user to enter employee information and display output: -using input(either scanner or jOption), allow user to...

  • Create a Console application for a library and name it FineForOverdueBooks. The Main( ) method asks...

    Create a Console application for a library and name it FineForOverdueBooks. The Main( ) method asks the user to input the number of books that are overdue and the number of days they are overdue. Pass those values to a method that displays the library fine, which is 10 cents per book per day for the first seven days a book is overdue, then 20 cents per book per day for each additional day. Grading criteria 1. Create a Console...

  • Integer Math- Console based---uses Windows Form in Visual Basic   Create an application that uses random integers...

    Integer Math- Console based---uses Windows Form in Visual Basic   Create an application that uses random integers to test the user’s knowledge of arithmetic. Let the user choose from addition, subtraction, multiplication, and division. The integers used in the problems should range from 20 to 120. When giving feedback, use color to differentiate between a correct answer response, versus an incorrect answer response. Also check for non-integer input. Preparing division problems requires special consideration because the quotient must be an integer....

  • answer the following using C# Design and program a Visual Studio Console project in C# that...

    answer the following using C# Design and program a Visual Studio Console project in C# that allows your user to enter a number. The program will examine the number to see if it is prime. If it is prime, it will print the next higher prime and the next lower primes to the console. If the number entered by the user is not prime, display a message to that effect. All code should be written by you. Do not copy/paste...

  • Hello Please, don't answer with your handwriting, Thank you.. This question is related to java language...

    Hello Please, don't answer with your handwriting, Thank you.. This question is related to java language Write a full Java program that: 1. Generate an integer random number between 0 and 6. 2. Then make a loop that keeps asking the user to guess the generated random number. If the user input is not equal to the generated random number, then print, "Try again" and allow the user to input another guess until the user guess correctly 3. If the...

  • Create a Java program application that creates an ArrayList that holds String objects. It needs to...

    Create a Java program application that creates an ArrayList that holds String objects. It needs to prompt the user to enter the names of friends, which are then put into the ArrayList; allow the user to keep adding names until they enter "q" to quit. After input is complete, display a numbered list of all friends in the list and prompt the user to enter the number of the friend they wish to delete. After deleting that entry, output the...

  • 7.30 - Guess-the-Number Game (Project Name: GuessTheNumber) - Write an app that plays “Guess the Number”...

    7.30 - Guess-the-Number Game (Project Name: GuessTheNumber) - Write an app that plays “Guess the Number” as follows: Your app chooses the number to be guessed by selecting a random integer in the range 1 to 1000. The app displays the prompt "Guess a number between 1 and 1000: ". The player inputs a first guess. If the player’s guess is incorrect, your app should display Too high. Try again. or Too low. Try again. to help the player “zero...

  • Write a C++ console application that allows your user to capture rainfall statistics. Your program should...

    Write a C++ console application that allows your user to capture rainfall statistics. Your program should contain an array of 12 doubles for the rainfall values as well as a parallel array containing the names of the months. Using each of the month names, prompt your user for the total rainfall for that month. The program should validate user input by guarding against rainfall values that are less than zero. After all 12 entries have been made, the program should...

  • Project 7-3 Guessing Game import java.util.Scanner; public class GuessNumberApp {    public static void main(String[] args)...

    Project 7-3 Guessing Game import java.util.Scanner; public class GuessNumberApp {    public static void main(String[] args) { displayWelcomeMessage(); // create the Scanner object Scanner sc = new Scanner(System.in); String choice = "y"; while (choice.equalsIgnoreCase("y")) { // generate the random number and invite user to guess it int number = getRandomNumber(); displayPleaseGuessMessage(); // continue until the user guesses the number int guessNumber = 0; int counter = 1; while (guessNumber != number) { // get a valid int from user guessNumber...

  • Please help: For this project, you will create a shape drawing program using Turtle graphics. Your...

    Please help: For this project, you will create a shape drawing program using Turtle graphics. Your program will begin by asking the user how many points they would like to enter (# of vertices for the shape). Next, you will use a loop to input each X and Y coordinate and store these coordinates in lists. After inputting all of the coordinates, create a second loop that will draw and fill the shape using the coordinates that were entered. All...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT