Create A program to Calculate GPA Of Student Of University in C#.
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Array_Practise1
{
class Program
{
static void Main(string[] args)
{
double tgpp=0, tchrs=0,gpa=0;
Console.WriteLine("Enter No Of Courses:");
int nc = Convert.ToInt32(Console.ReadLine());
string[] cname = new string[nc];
double[] chrs = new double[nc];
double[] marks = new double[nc];
string[] grade = new string[nc];
double[] gp = new double[nc];
double[] gpp = new double[nc];
for (int i = 0; i < nc; i++)
{
Console.WriteLine("Enter Course Title:");
cname[i] = Console.ReadLine();
Console.WriteLine("Enter Credit Hours Of Course:");
chrs[i] =double.Parse (Console.ReadLine());
Console.WriteLine("Enter Marks Of Course");
marks[i] = double.Parse(Console.ReadLine());
if (marks[i]>=85)
{
grade[i] = "A";
gp[i] = 4.00;
}
if (marks[i] >= 80 && marks[i]<85)
{
grade[i] = "A-";
gp[i] = 3.67;
}
else if (marks[i] >= 75 && marks[i] < 80)
{
grade[i] = "B+";
gp[i] = 3.33;
}
else if (marks[i] >= 71 && marks[i] <75)
{
grade[i] = "B";
gp[i] = 3.00;
}
else if (marks[i] >= 68 && marks[i] < 71)
{
grade[i] = "B-";
gp[i] = 2.67;
}
else if (marks[i] >= 64 && marks[i] < 68)
{
grade[i] = "C+";
gp[i] = 2.33;
}
else if (marks[i] >= 60 && marks[i] < 64)
{
grade[i] = "C";
gp[i] = 2.00;
}
else if (marks[i] >= 57 && marks[i] < 60)
{
grade[i] = "C-";
gp[i] = 1.67;
}
else if (marks[i] >= 53 && marks[i] < 57)
{
grade[i] = "D+";
gp[i] = 1.33;
}
else if (marks[i] >= 50 && marks[i] < 53)
{
grade[i] = "D";
gp[i] = 1.00;
}
else if ( marks[i] < 50)
{
grade[i] = "F";
gp[i] = 0.00;
}
gpp[i] = gp[i] * chrs[i];
tgpp =tgpp + gpp[i];
tchrs += chrs[i];
}
gpa = tgpp / tchrs;
Console.Clear();
Console.WriteLine("===============Mark Sheet================");
Console.WriteLine("Course Title\t chrs\t Marks\t Grade\t GPP");
Console.WriteLine("---------------------------------------------");
for (int i = 0; i < nc; i++)
{
Console.WriteLine("{0}\t\t| {1}\t| {2}\t| {3}\t| {4}\t|",cname[i]
,chrs[i],marks[i],grade[i],gpp[i]);
}
Console.WriteLine("\nTotal GPA:{0}",gpa);
}
}
}
Comments
Post a Comment