一、运行效果截图
![](https://i-blog.csdnimg.cn/blog_migrate/2d97a3e10ae82892eddbe7bb14324516.png)
![](https://i-blog.csdnimg.cn/blog_migrate/31b6d0dac62ed768043e5b6488bdb991.png)
二、实验要求
![](https://i-blog.csdnimg.cn/blog_migrate/6db08e005df0f94221135a26f4dbd073.png)
三、代码示例
//author---Henan University.software engineering.李思佳
using System;
namespace ConsoleApp6
{
enum Grade
{
one=1,
two=2
}
class Teach
{
private Random r = new Random();
private int x;
private int y;
private int times = 0;
private Grade grade = Grade.one;
private void Question()
{
if(grade==Grade.one)
{
x = r.Next(1, 10);
y = r.Next(1, 10);
}
else
{
x = r.Next(10, 100);
y = r.Next(10, 100);
}
}
public void Start()
{
Console.WriteLine("please choose your grade 1 or 2 :");
var g = Console.ReadLine();
grade = (Grade)Convert.ToInt32(g);
Console.WriteLine("☆☆☆Start!☆☆☆");
Console.WriteLine();
while(times<3)
{
Console.WriteLine("Question {0} :", times + 1);
Question();
while(true)
{
Console.WriteLine("How much is {0} times {1} ?", x, y);
int answer = Convert.ToInt32(Console.ReadLine());
if(answer==x*y)
{
Console.WriteLine("Very good!");
times++;
break;
}
else
{
Console.WriteLine("No, please try again.");
}
}
Console.WriteLine();
}//while
Console.WriteLine("☆☆☆You are smart !☆☆☆");
}//Start()
}//Teach()
class Program
{
static void Main(string[] args)
{
//计算机辅助教学
Teach s1 = new Teach();
s1.Start();
Console.ReadLine();
}
}
}