【发布时间】:2015-10-26 02:00:34
【问题描述】:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Combine
{
class Program
{
public void marks()
{
int marks;
string Grade = null; // The initial value of grade is 0.
//Prompt User
Console.WriteLine("Please enter your mark here");
marks = int.Parse(Console.ReadLine());
if (marks < 0 || marks > 100)
{
Console.WriteLine("mark entered is not valid");
}
else
{
if (marks >= 85 && marks <= 100)
{
Grade = "A";
}
else if (marks >= 70 && marks <= 84)
{
Grade = "B";
}
else if (marks >= 60 && marks <= 69)
{
Grade = "C";
}
else if (marks >= 50 && marks <= 59)
{
Grade = "D";
}
else if (marks >= 0 && marks <= 49)
{
Grade = "F";
}
Console.WriteLine("grade is a " + Grade + " grade");
}
Console.ReadLine();
}
static void Main(string[] args)
{
// INTRO TO APP //
string b;
string bselect;
Program p = new Program();
Console.WriteLine("Welcome");
Console.WriteLine("Please Select A Menu Item");
bselect = Console.ReadLine();
b = bselect;
if (bselect == b )
Console.WriteLine("B - Body Mass Index")
}
{
Console.WriteLine("L - Letter Grade");
string lselect;
string l;
Program p = new Program();
lselect = Console.ReadLine();
l = lselect;
p.marks();
}
{
string t;
Console.WriteLine("T - Tax Due");
t = Console.ReadLine();
}
{
string x;
Console.WriteLine("X - Exit");
x = Console.ReadLine();
}
}
}
}
为此,我尝试将三个控制台应用程序合并为一个,并通过一个简单的菜单选项来选择要运行的应用程序。我知道我应该使用方法,但我不确定如何正确使用它们。我用谷歌搜索,但没有一个我能真正理解的信息。谢谢。
【问题讨论】:
-
多余的括号是怎么回事?
-
你能确定应该运行的 3 个函数吗?从您发布的代码来看,编译器不会编译,而且似乎不合逻辑......
-
我只是想知道如何使用主菜单选项界面将三个应用程序合并为一个。