宇宙黑暗森林博弈论
2018-08-20 17:51
做了个计算器程序,但是输入运算符号那步直接跳过去了
Console.WriteLine("请输入第一个数");
float oneNumberInCalculator;
oneNumberInCalculator = Console.Read();
Console.WriteLine("请输入运算符号");
Console.WriteLine("1为加,2为减,3为乘,4为除");
int arithmeticSymbol;
arithmeticSymbol = Console.Read();
if (arithmeticSymbol == 1)
{
Console.WriteLine("请输入第二个数");
float twoNumberInCalculater;
twoNumberInCalculater = Console.Read();
Console.WriteLine("运算结果为");
Console.WriteLine(oneNumberInCalculator + twoNumberInCalculater);
}
if (arithmeticSymbol == 2)
{
Console.WriteLine("请输入第二个数");
float twoNumberInCalculater;
twoNumberInCalculater = Console.Read();
Console.WriteLine("运算结果为");
Console.WriteLine(oneNumberInCalculator - twoNumberInCalculater);
}
if (arithmeticSymbol == 3)
{
Console.WriteLine("请输入第二个数");
float twoNumberInCalculater;
twoNumberInCalculater = Console.Read();
Console.WriteLine("运算结果为");
Console.WriteLine(oneNumberInCalculator * twoNumberInCalculater);
}
if (arithmeticSymbol == 4)
{
Console.WriteLine("请输入第二个数");
float twoNumberInCalculater;
twoNumberInCalculater = Console.Read();
Console.WriteLine("运算结果为");
Console.WriteLine(oneNumberInCalculator / twoNumberInCalculater);
}
Read
C#开发轻松入门
254118 学习 · 1459 问题
相似问题
回答 4
回答 2