© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
52 replies
torpschez

cant figure out how to calculate averages

using System;

namespace MyApp

{
internal class Program
{
static void Main(string[] args)
{
Intro();
double test1 = score1("Please enter the score of the first test");
while (test1 > -999)
{
test1 = score1("Please enter the score of your test");
}
double total = grade(test1);
letter(total);
Ending();
}
public static void Intro()
{
Console.Title = ("EX38");
Console.WindowHeight = 15;
Console.WindowWidth = 60;
Console.ForegroundColor = ConsoleColor.Green;

}

public static double score1(string s)
{
Console.WriteLine(s);
double test1 = Convert.ToDouble(Console.ReadLine());
return test1;
}

public static double grade(double test1)
{
double total = (test1+999) / 5;
Console.WriteLine("The average of the grades is {0:f1}", total);
return total;
}

public static void letter(double total)
{
if (total > 89)
{
Console.WriteLine("This is an A");

}
if (total < 89 && total > 79)
{
Console.WriteLine("This is an B");

}
if (total < 79 && total > 69)
{
Console.WriteLine("This is an C");

}
if (total < 69 && total > 59)
{
Console.WriteLine("This is an D");

}
if (total < 59)
{
Console.WriteLine("This is an F");
}
}
public static void Ending()
{
Console.SetCursorPosition(Console.WindowWidth / 2 - 15, Console.WindowHeight - 2);
Console.WriteLine("Press enter twice to close window.");
Console.ReadLine();
}
}
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements
Next page

Similar Threads

I cant figure out constructor inheritance
C#CC# / help
3y ago
I cant figure out how to add a subprocess to my app
C#CC# / help
14mo ago
Cant figure out what these checkboxes are
C#CC# / help
2y ago
Cant figure out how to change font/background colors of flow charts.
C#CC# / help
8mo ago