static void getGrades()
{
Console.WriteLine("How many grade level classes are you taking?");
int standardNumber = int.Parse(Console.ReadLine());
Console.WriteLine();
Console.WriteLine("How many honors level classes are you taking?");
int honorsNumber = int.Parse(Console.ReadLine());
Console.WriteLine();
Console.WriteLine("How many AP level classes are you taking?");
int apNumber = int.Parse(Console.ReadLine());
Console.WriteLine();
Console.WriteLine("Enter your letter grades when prompted.");
Console.WriteLine("=======================================");
for (int a = 1; a == standardNumber; a++)
{
int num = 1;
Console.WriteLine("Enter letter grade for honors class {0}:", num);
switch (num)
{
case 1:
string class1 = Console.ReadLine();
break;
case 2:
string class2 = Console.ReadLine();
break;
case 3:
string class3 = Console.ReadLine();
break;
case 4:
string class4 = Console.ReadLine();
break;
default:
break;
}
Console.WriteLine();
}
}
我試圖調用此方法來收集4個類的混合中的類和級別字母的數量。當我調用方法時,第一部分(下面)執行正常。未運行方法的一部分
Console.WriteLine("How many grade level classes are you taking?");
int standardNumber = int.Parse(Console.ReadLine());
Console.WriteLine();
Console.WriteLine("How many honors level classes are you taking?");
int honorsNumber = int.Parse(Console.ReadLine());
Console.WriteLine();
Console.WriteLine("How many AP level classes are you taking?");
int apNumber = int.Parse(Console.ReadLine());
但是,其餘的代碼(下面)不執行。
Console.WriteLine();
Console.WriteLine("Enter your letter grades when prompted.");
Console.WriteLine("=======================================");
for (int a = 1; a == standardNumber; a++)
{
int num = 1;
Console.WriteLine("Enter letter grade for honors class {0}:", num);
switch (num)
{
case 1:
string class1 = Console.ReadLine();
break;
case 2:
string class2 = Console.ReadLine();
break;
case 3:
string class3 = Console.ReadLine();
break;
case 4:
string class4 = Console.ReadLine();
break;
default:
break;
}
Console.WriteLine();
}
}
有誰知道爲什麼會發生這種情況。在此先感謝
你想在這裏做什麼? – Sajeetharan
我正在嘗試獲取每種類型的課程(例如2個榮譽課程和2個課程課程),然後使用循環從該課程的許多課程中獲得信件成績。 – zstaylor
檢查答案 – Sajeetharan