Alone, not to the Yellow River not to forget

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.