60 331
Assignments Done
98%
Successfully Done
In April 2018

# Answer to Question #29206 in C# for terror

Question #29206
a program that first asks for two integer values A and B,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.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QuessNumber
{
class Program
{
static void Main(string[] args)
{
int A,B;//declare A and b
int inputnumber = 0;//input number
Console.Write(&quot;Enter number A: &quot;);
Console.Write(&quot;Enter number B: &quot;);

Random rand=new Random();
int guessnumber = rand.Next(A, B);//Random number
while (inputnumber != guessnumber) {
Console.Write(&quot;What the number is: &quot;);
if (inputnumber &lt; guessnumber)
{
Console.WriteLine(&quot;Too low!!!&quot;);//show Too low
}
else if (inputnumber &gt; guessnumber)
{
Console.WriteLine(&quot;Too high!!!&quot;);//show Too high
}else{
break ;
}

if (inputnumber &lt; A && inputnumber &gt; B) {
Console.WriteLine(&quot;Quess was outside the range between A and
B&quot;);//Quess was outside the range between A and B
}
}
Console.WriteLine(&quot;You are right!!!&quot;);//show You are right
Console.WriteLine(&quot;&quot;);
Console.WriteLine(&quot;Press any key to exit...&quot;);//Press any key to exit

}
}
}

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!