2、从键盘上输入两个整数,由用户回答它们的和,差,积,商和取余运算结果,并统计出正确答案的个数。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace project2
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 0;
            Console.WriteLine("please enter a integer");
            int x = int.Parse(Console.ReadLine());                                                 // 将Console.ReadLine()得出来的字符串转换为整型(int)
            Console.WriteLine("please ener anther integer");
            int y = int.Parse(Console.ReadLine());
            int sum = x + y;
            int difference = x - y;
            int product = x * y;
            int quotient = x / y;
            int remainder = x % y;
            Console.WriteLine("please answer their sum:");
            int he = int.Parse(Console.ReadLine());
            if(he==sum)
            {
                i++;
            }
            Console.WriteLine("please answer the difference:");
            int cha=int.Parse(Console.ReadLine());
            if(cha==difference)
            {
                i++;
            }
            Console.WriteLine("please answer the product:");
            int chengji = int.Parse(Console.ReadLine());
            if(chengji==product)
            {
                i++;
            }
            Console.WriteLine("please answer the quotient:");
            int shang = int.Parse(Console.ReadLine());
            if(shang==quotient)
            {
                i++;
            }
            Console.WriteLine("please answer the remainder:");
            int yu = int.Parse(Console.ReadLine());
            if(yu==remainder)
            {
                i++;
            }
            Console.WriteLine("the correct answer number:{0}",i);
            Console.ReadKey();

        }
    }
}

你可能感兴趣的:(工作室作业)