Finished Challenge: Taking User Input from Console; By myself

jason.zhu 2021-02-22 00:12:35 +00:00
parent 8d917a0c57
commit 5ea0c1bd54
1 changed files with 25 additions and 6 deletions

View File

@ -8,15 +8,34 @@ namespace GradeBook
static void Main(string[] args)
{
var book = new Book("Scott's Grade Book");
book.AddGrade(89.1);
book.AddGrade(90.5);
book.AddGrade(87.2);
// var book = new Book("Scott's Grade Book");
// book.AddGrade(89.1);
// book.AddGrade(90.5);
// book.AddGrade(87.2);
var book = new Book("Jason's Grade Book");
string input;
bool if_continue = true;
while (if_continue)
{
Console.WriteLine("Give input: ");
input = Console.ReadLine();
if (input == "Q" || input == "q")
{
Console.WriteLine("Receiving termination signal; Termiate program");
break;
} else
{
Console.WriteLine($"Received: {input}");
book.AddGrade(Convert.ToDouble(input));
}
}
var stats = book.GetStatistics();
Console.WriteLine($"The lowest grade is {stats.lowGrade}");
Console.WriteLine($"The highest grade is {stats.highGrade}");
Console.WriteLine($"The highesst grade is {stats.highGrade}");
Console.WriteLine($"The average grade is {stats.Average:N1}");
}
}