I get the command prompt to come up and get the correct answer for Bad Score, but if I try to type in a good grade (800) it does nothing. Any help would be greatly appreciated. I am new to this so I apologize my coder isn't pretty.
//variables
string firstName, lastName, grades = "";
double points = 0, percent = 0;
//Greeting
Console.WriteLine("The purpose of this program is to allow the teacher to calculate the percentage and final grade for students in their class.");
//Display and Inputs
Console.WriteLine("\n\nPlease enter the students first name.");
firstName = Console.ReadLine();
Console.WriteLine("\n\nPlease enter the students last name.");
lastName = Console.ReadLine();
Console.WriteLine("\n\nPlease enter the points that the student received.\n\n");
points = Convert.ToDouble(Console.ReadLine());
//Display after points are entered
if (points < 0 || points > 1000 )
{
Console.WriteLine("Bad Score!");
}
else
{
percent = points / 1000;
if (percent >= .9)
{
grades = "A";
}
else if (percent >= .8)
{
grades = "B";
}
if (percent >= .7)
{
grades = "C";
}
else if (percent >= .6)
{
grades = "D";
}
if (percent >= .0)
{
grades = "F";
}
else
{
Console.WriteLine("WRONG!!");
}
}
grades = Console.ReadLine();
//Outputs
Console.WriteLine(firstName);
Console.WriteLine(lastName);
Console.WriteLine(points);
Console.WriteLine(percent.ToString("P"));
Console.WriteLine("so they made an" + grades);
//Closing statement
Console.WriteLine("Goodbye");
Environment.Exit(1);
}
}
}
Aucun commentaire:
Enregistrer un commentaire