Grade Calculator Program in C#(Sharp)
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace cgpga { class Program { static void Main(string[] args) { // creating the program for calculate the CGPA from percentage double first, second, third, fourth, fifth,CGPA; char option; Console.Write("Enter the Number of first subject "); first = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter the Number of second subject "); second = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter the Number of third subject "); third = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter the Number of fourth subject "); fourth = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter the Number of fifth subject "); fifth = Convert.ToDouble(Console.ReadLine()); CGPA = ((first + second + third + fourth + fifth) / 5) / 9.5; // we are divide percentage to 9.5 for calculating the CGPA Console.WriteLine("Your CGPA is=>"+CGPA); if (CGPA >= 8) // checking the condition for the Grad. { option = '1'; } else if (CGPA >= 6.5 && CGPA <8) { option = '2'; } else if (CGPA >= 3.5 && CGPA < 6.5) { option = '3'; } else { option = 'F'; } switch (option) //checking the condition for the Grad { case '1': Console.WriteLine("Grade: First Class with Distinction"); break; case '2':Console.WriteLine("Grade: second Class");break; case '3':Console.WriteLine("Grade: Third Class Class");break; case 'F':Console.WriteLine("Grade: Fail");break; default:Console.WriteLine("Invalid GRADE");break; } Console.ReadLine(); } } }
Output==>
No comments:
Post a Comment