Third assignment: random arithmetic of 0~10

Source: Internet
Author: User

Although the holiday before the girls to the same dorm to get the software to my USB flash drive, but the results are not installed on the home, so just in the Notepad code. The result can not run actually I do not know, just put some code to send up.

Here's my Code.

namespace add
{
Class Program
{
static void Main (string[] args)
{
int right=0;
int wrong=0;
Do
{
Random sj=new random ();
int X=SJ. Next (0,11);
int Y=SJ. Next (1,3);
Console.WriteLine ("Please select an operation +,-, *,/; or press ENTER to end the process");
String i=convert.tostring (Console.ReadLine ());
if (i = = "+")
{
Console.WriteLine ("{0}+{1}=", x, y);
int Z=conver.toint32 (Console.ReadLine ());
if (z = = x + y)
{
right++;
}
Else
{
Console.WriteLine ("Sorry, answer wrong!") ");
wrong++;
}
}
Else
if (i = = "-")
{
Console.WriteLine ("{0}-{1}=", x, y);
int Z=conver.toint32 (Console.ReadLine ());
int (z ==x-y)
{
right++;
}
Else
{
Console.WriteLine ("Sorry, answer wrong!") ");
wrong++;
}
}
Else
if (i = = "*")
{
Console.WriteLine ("{0}*{1}=", x, y);
int Z=conver.toint32 (Console.ReadLine ());
if (z = = x * y)
{
right++;
}
Else
{
Console.WriteLine ("Sorry, answer wrong!") ");
wrong++;
}
}
Else
if (i = = "/")
{
Console.WriteLine ("{0}/{1}=", x, y);
int z = conver.toint32 (Console.ReadLine ());
if (z = = x/y)
{
right++;
}
Else
{
Console.WriteLine ("Sorry, answer wrong!") ");
wrong++;
}
}
}
while (Console.ReadLine ()! = "P");
Console.WriteLine ("You answered {0}, correct: {1}, Error: {2}", Right+wrong,right,wrong);
Console.ReadLine ();
}
}
}

This is my code, I go back to school tomorrow will run first, if not successful, I will improve again.

Third assignment: random arithmetic of 0~10

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.