76 775
Assignments Done
Successfully Done
In June 2019

Answer to Question #4646 in C# for richard rooks

Question #4646
how do you create a program that first asks for two integer values A and B. Your program should
then pick a random number between A and B and keep it secret. Then ask the user to
guess what the number is. The program should continue to ask the user to guess, until
the user gets the correct answer. Each time the user makes an incorrect guess, the
program should tell the user if the guess was too high, or too low. The program should
also tell the user if the guess was outside the range between A and B.
Expert's answer
using System;
using System.Collections.Generic;
using System.Text;

namespace questions_CSharp

class Program
& static void Main(string[] args)
int A = 0, B = 0, C = 0, userNumber = 0;
rand = new Random();
Console.Write("Please, enter A:
A = Convert.ToInt32(Console.ReadLine());

Console.Write("Please, enter B: ");
B =
C = rand.Next(A,
Console.WriteLine("Secret Number is
Console.WriteLine("Try to guess
while (true)

Console.Write("Your Answer: ");
userNumber =

if (userNumber == C)

& Console.WriteLine("Congratulations!
Your Answer is right!");
& break;

if (userNumber < A || userNumber > B)
Console.WriteLine("Number is outside the range between A and B. Try
if (userNumber < C) Console.WriteLine("Number is
to low");
if (userNumber > C) Console.WriteLine("Number is
to high");
Console.WriteLine("Have a nive day.
To exit press any button...");

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions