Write a program to calculate and display your average and grade. Allow the user to enter five
scores. After values are entered, and the average calculated, test the result to determine whether
an A, B, C, D, D, F should be recorded. The scoring rubric is as follows: A- 90 – 100; B- 80-89;
C- 70-79; D- 60-69; F < 60. Use methods.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StudentGrade
{
class Program
{
static void Main(string[] args)
{
CalculateGrade();
}
private static void CalculateGrade()
{
float score, sum = 0, avg = 0; int i;
for (i = 1; i <= 5; i++)
{
Console.WriteLine("Enter your :{0} Score", i);
score = float.Parse(Console.ReadLine());
sum = sum + score;
}
avg = sum / (i - 1);
Console.WriteLine("Average:" + avg);
if (avg >= 90 && avg <= 100)
Console.WriteLine(" Grade: A");
else if (avg >= 80 && avg <= 89)
Console.WriteLine(" Grade: B");
else if (avg >= 70 && avg <= 79)
Console.WriteLine(" Grade: C");
else if (avg >= 60 && avg <= 69)
Console.WriteLine(" Grade: D");
else
Console.WriteLine(" Grade: F");
Console.Read();
}
}
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C#