そこで、最近、A レベルのコンピューティング クラスの一環として電卓を作成しましたが、問題なく機能し、先生から BMI 電卓を追加するように言われました。これも正常に機能しますが、問題は電卓が実行されないことです。コードは次のとおりです。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Calculator1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello! Type BMI to head to the BMI Calulator");
Console.WriteLine("If you want a calculator -- Here are your commands:");
Console.WriteLine("TIMES - ADD - SUBTRACT - DIVIDE");
string text = Console.ReadLine();
if (text == "BMI")
{
Console.Clear();
Console.WriteLine("Welcome to the BMI Calcualtor! Please enter your height (M)");
string height = Console.ReadLine();
Double height1 = Convert.ToDouble(height);
Double height2 = height1 * height1;
Double heightB = Convert.ToDouble(height2);
Console.Clear();
Console.WriteLine("Please enter your Weight(KG)");
string weight = Console.ReadLine();
int weight1 = Convert.ToInt32(weight);
Double weightA = Convert.ToDouble(weight1);
Double fbmi = weightA / heightB;
Console.WriteLine(fbmi);
if (fbmi < 18.5)
{
Console.WriteLine("UnderWeight");
Console.ReadLine();
}
if (fbmi > 18.5&& fbmi < 25.0)
{
Console.WriteLine("Normal");
Console.ReadLine();
}
if (fbmi > 25.0 && fbmi < 29.9)
{
Console.WriteLine("OverWeight");
Console.ReadLine();
}
if (fbmi > 29.9 && fbmi < 40.0)
{
Console.WriteLine("Obese");
Console.ReadLine();
}
if (fbmi > 40.1)
{
Console.WriteLine("Extremely Obese");
Console.ReadLine();
}
if (text == "TIMES")
{
Console.WriteLine("Enter your first number");
string number = Console.ReadLine();
int NumberA = Convert.ToInt32(number);
Console.WriteLine("Enter your second number");
string number1 = Console.ReadLine();
int NumberB = Convert.ToInt32(number1);
Console.WriteLine("");
Console.WriteLine("============");
Console.WriteLine("ANSWER");
Console.WriteLine("============");
Console.WriteLine(NumberA * NumberB);
Console.ReadLine();
}
if (text == "ADD")
{
Console.WriteLine("Enter your first number");
string number = Console.ReadLine();
int NumberA = Convert.ToInt32(number);
Console.WriteLine("Enter your second number");
string number1 = Console.ReadLine();
int NumberB = Convert.ToInt32(number1);
Console.WriteLine("");
Console.WriteLine("============");
Console.WriteLine("ANSWER");
Console.WriteLine("============");
Console.WriteLine(NumberA + NumberB);
Console.ReadLine();
}
if (text == "SUBTRACT")
{
Console.WriteLine("Enter your first number");
string number = Console.ReadLine();
int NumberA = Convert.ToInt32(number);
Console.WriteLine("Enter your second number");
string number1 = Console.ReadLine();
int NumberB = Convert.ToInt32(number1);
Console.WriteLine("");
Console.WriteLine("============");
Console.WriteLine("ANSWER");
Console.WriteLine("============");
Console.WriteLine(NumberA - NumberB);
Console.ReadLine();
}
if (text == "DIVIDE")
{
Console.WriteLine("Enter your first number");
string number = Console.ReadLine();
int NumberA = Convert.ToInt32(number);
Console.WriteLine("Enter your second number");
string number1 = Console.ReadLine();
int NumberB = Convert.ToInt32(number1);
Console.WriteLine("");
Console.WriteLine("============");
Console.WriteLine("ANSWER");
Console.WriteLine("============");
Console.WriteLine(NumberA / NumberB);
Console.ReadLine();
}
}
}
}
}
だから、どんな助けも大歓迎です:)