Follow the examples you've done before, and combine them to make a little change.
Here is the program code: (a bit messy)
PSP Time-consuming analysis:
Summary: For me, a bit difficult, indeed it is also very helpful, I believe, will do better in the future, refueling!
Study questions: If the user requests a range of 0--100, how the program should be designed to handle extensibility easily.
Just put: int x= SjS. Next (0,11);
int y =sjs. Next (0,11), instead:
int x= SjS. Next (0,101);
int y =sjs. Next (0,101);
Can.
The code is as follows:
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Namespace ConsoleApplication1
{
Class Program
{
static void Main (string[] args)
{
Console.WriteLine ("------Calculator manual------");
Console.WriteLine ("Subtraction, respectively, represented by +-*/");
Console.WriteLine ("What is needed to knock out what kind of");
Do
{
Random SJS = new Random ();
int x = SjS. Next (0, 11);
int y = SjS. Next (0, 11);
int j = 0;
int k = 0;
String a = Console.ReadLine ();
if (A = = "+")
{
Console.WriteLine ("{0}+{1}=", x, y);
int b = Convert.ToInt32 (Console.ReadLine ());
if (b = = x + y)
{
Console.WriteLine ("You Are Right");
j + +;
}
Else
{
Console.WriteLine ("Stupid, not so easy!") ");
k++;
}
}
Else
if (A = = "-")
{
Console.WriteLine ("{0}-{1}=", x, y);
int b = Convert.ToInt32 (Console.ReadLine ());
if (b = = x-y)
{
Console.WriteLine ("You Are Right");
j + +;
}
Else
{
Console.WriteLine ("Stupid, not so easy!") ");
k++;
}
}
Else
if (A = = "*")
{
Console.WriteLine ("{0}*{1}=", x, y);
int b = Convert.ToInt32 (Console.ReadLine ());
if (b = = x * y)
{
Console.WriteLine ("You Are Right");
j + +;
}
Else
{
Console.WriteLine ("Stupid, not so easy!") ");
k++;
}
}
Else
if (A = = "/")
{
Console.WriteLine ("{0}/{1}=", x, y);
int b = Convert.ToInt32 (Console.ReadLine ());
if (b = = x/y)
{
Console.WriteLine ("You Are Right");
j + +;
}
Else
{
Console.WriteLine ("Stupid, not so easy!") ");
k++;
}
}
Console.WriteLine ("You did {0}, correct {1}, answer the question {2}"! ", j+k,j,k);
}
while (Console.ReadLine ()! = "V");
Console.ReadLine ();
}
}
}
Alone, not to the Yellow River not to forget