So I am trying to create a gradeing program where the user inputs a number between 1-100 on subjects; math, gym and classroom and the average number comes up that gives the student a grade between A-F.
I am stuck at looping, i dont know how to code so that if I type in an average of ex 80 points the grade B comes up. It comes up unreachble code detected.
static string GradeMe(int average)
{
const int grades1 = 90;
const int grades2 = 75;
if (grades1 >= 90 && grades1 <= 100)
{
return "Grade A";
}
(???->) else if (grades2 >= 75 && grades32 <= 89) {return "Grade B";}
}
static int CalculateAverageGrades(int math, int gym, int classroom)
{
int sum = math + gym + classroom;
return sum / 3;
}
static void Main(string[] args)
{
Console.WriteLine("math: ");
int tenta = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("gym: ");
int dugga = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("classroom: ");
int projekt = Convert.ToInt32(Console.ReadLine());
int medeltal = CalculateAverageGrades(math, gym, classroom); //hämtar calculate metoden
Console.WriteLine("medel: " + medeltal);
string grade = GradeMe(medeltal);
Console.WriteLine(grade);
Aucun commentaire:
Enregistrer un commentaire