Add project files.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<RootNamespace>GPA_Calculator</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace GPA_Calculator
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static List<Grade> GradesList = new List<Grade>();
|
||||
static void Main(string[] args)
|
||||
{
|
||||
|
||||
string inputGrade = string.Empty;
|
||||
while (inputGrade != "q")
|
||||
{
|
||||
RenderGrades();
|
||||
inputGrade = Console.ReadLine();
|
||||
inputGrade = inputGrade.Replace("+", "Plus").Replace("-", "Minus");
|
||||
if(Enum.TryParse<Grade>(inputGrade, out Grade grade))
|
||||
{
|
||||
GradesList.Add(grade);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void RenderGrades()
|
||||
{
|
||||
Console.Clear();
|
||||
Console.WriteLine("Enter a Grade:\t\t\tGrades:");
|
||||
decimal totalGrade = 0;
|
||||
foreach (var item in GradesList)
|
||||
{
|
||||
Console.WriteLine("\t\t\t\t" + item.ToString().Replace("Plus", "+").Replace("Minus", "-"));
|
||||
totalGrade += (int)item;
|
||||
}
|
||||
if (GradesList.Count > 0)
|
||||
{
|
||||
Console.SetCursorPosition(0, 3);
|
||||
Console.WriteLine("GPA: ");
|
||||
Console.WriteLine(totalGrade / GradesList.Count);
|
||||
}
|
||||
|
||||
Console.SetCursorPosition(0, 1);
|
||||
|
||||
}
|
||||
|
||||
enum Grade
|
||||
{
|
||||
APlus = 9,
|
||||
A = 8,
|
||||
AMinus = 7,
|
||||
BPlus = 6,
|
||||
B = 5,
|
||||
BMinus = 4,
|
||||
CPlus = 3,
|
||||
C = 2,
|
||||
CMinus = 1,
|
||||
Fail = 0,
|
||||
F = 0,
|
||||
D = 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user