using System;
using System.Collections.Generic;
using System.Text;
namespace _._7练习_三_计算机练习
{
class Program
{
static void Main(string[] args)
{
//下面是一个while循环
string str = "Y";//先声明变量等于空值
while (str == "Y" || str == "y")
{
//下面是主程
int num1 = Convert.ToInt32(Console.ReadLine());
int num2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("选择要进行的操作,+代表相加,-代表相减,*代表相乘,/代表相除");
string operater = Console.ReadLine();
switch (operater)//判断operater是否加减乘除
{
case "+":
Console.WriteLine("相加的结果为:" + (num1 + num2).ToString());
break;
case "-":
Console.WriteLine("相减的结果为:" + (num1 - num2).ToString());
break;
case "*":
Console.WriteLine("相乘的结果为:" + (num1 * num2).ToString());
break;
default:
Console.WriteLine("相除的结果为:" + (num1 / num2).ToString());
break;
}
//Console.Read();有while时这里可以不要
Console.WriteLine("是否继续进行计算,Y代表继续,N代表退出");
str = Console.ReadLine();//重新给str赋值
}//while循环括号
}
}
}
阅读(671) | 评论(0) | 转发(0) |