namespace _7._39
{
class Program
{
static void Main(string[] args)
{
string response1;
string response2;
string response3;
string response4;
Random resp = new Random();
bool correct = Question();// Create a value to call the question method
if (correct== true)// when the answer is true it return very good
{
Console.WriteLine("Very Good!");
}
else// when the answer is false it returns to try again
{
Console.WriteLine("No please try again");
}
}
public static bool Question()
{
Random rand = new Random();// we create a random number
int num = rand.Next(1, 9);// first random number between 1 and 9
int num1 = rand.Next(1, 9);// second random number between 1 and 9
int ans = num * num1;// the value of multiplication between 1 and 2
// asking what the two values are multiplied
Console.WriteLine("What is"+ num.ToString()+ "*" +num1.ToString());
// reads the users attempt
int attempt = int.Parse(Console.ReadLine());
if (attempt == ans)// when the attempt is equal to the answer
{
return true;// its returns true bool
}
else// if it is false it says no please try again
{
Console.WriteLine("No please try again");
return Question();// and creates a new question for the user
}
}
}
}
I need my correct== true and false to respond with a random response among 4 possible choices. I need to do this by doing a switch statement to issue each response. Also by using random to select which response comes up.
Very good!
Excellent!
Nice work!
Keep up the good work!
and 4 options for a false response as well
Aucun commentaire:
Enregistrer un commentaire