我必须编写一个程序,使用Method提示用户选择菜单。
我试着写点什么,但我失败了。 :,(
这是我的代码。
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Choose a Menu");
Console.WriteLine("1: Calculate Area");
Console.WriteLine("2: Calculate Volume");
Console.WriteLine("3: Calculate Surface Area");
Console.WriteLine("0: Exit the program");
int number = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(calculateTotal(number));
}
public static int calculateTotal(int number)
{
switch (number)
{
case 1:
Console.WriteLine("Calculate Area");
Console.Write("Input Length\t");
int L1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Input Width\t");
int W1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Area is\t");
Console.WriteLine(L1 * W1);
Console.ReadLine();
break;
case 2:
Console.WriteLine("2: Calculate Volume");
Console.Write("Input Length\t");
int L2 = Convert.ToInt32(Console.ReadLine());
Console.Write("Input Width\t");
int W2 = Convert.ToInt32(Console.ReadLine());
Console.Write("Input Height\t");
int H2 = Convert.ToInt32(Console.ReadLine());
Console.Write("Volume is\t");
Console.WriteLine(L2 * W2 * H2);
Console.ReadLine();
break;
case 3:
Console.WriteLine("3: Calculate Surface Area");
Console.Write("Input Length\t");
int L3 = Convert.ToInt32(Console.ReadLine());
Console.Write("Input Width\t");
int W3 = Convert.ToInt32(Console.ReadLine());
Console.Write("Surface Area is\t");
Console.WriteLine(L3 * W3 * 2);
Console.ReadLine();
break;
case 0:
Console.WriteLine("Exit the program now");
break;
default:
Console.WriteLine("ERROR: Invalid Choice");
break;
}
}
}
这是我的问题
'Program.calculateTotal(int)':not all code paths return a value
我是编程的超级初学者 你能帮我找个问题吗?