Pages

Make a programme to calculate GPA and CGPA by taking input numbers to the user.

INPUT:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication22
{
    class Program
    {
        static void Main(string[] args)
        {

            double p_age, o_marks,ta_gpa;
            int t_marks = 100;
            double tp_gpa=0;
            double gpa, t_gpa;
            for (int i = 1; i <= 6; i++)
            {
                string[] sub = new string[1];
                int[] quiz = new int[1];
                int[] crdhour = new int[1];
                int[] mid = new int[1];
                int[] final = new int[1];
                int[] asig = new int[1];
                int[] t_crdhour = new int[1];

                Console.WriteLine("enter the subject{0} name", i);
                sub[0] = Console.ReadLine();
                Console.WriteLine("enter total credit hour of {0}",sub[0]);
                t_crdhour[0] = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("enter assigment marks of {0}", sub[0]);
                asig[0] = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("enter quiz marks of {0}", sub[0]);
                quiz[0] = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("enter mid term marks of {0}", sub[0]);
                mid[0] = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("enter final term marks of {0}", sub[0]);
                final[0] = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("How many  credit our did u attend of {0}", sub[0]);
                crdhour[0] = Convert.ToInt32(Console.ReadLine());
                o_marks = asig[0] + quiz[0] + mid[0] + final[0];
                p_age = (o_marks * 100) / t_marks;
                {
                    if ((p_age < 101) && (p_age > 86))
                    {
                        gpa = 4.0;
                    }
                    else
                        if ((p_age < 87) && (p_age > 79))
                        {
                            gpa = 3.5;
                        }
                        else
                            if ((p_age < 80) && (p_age > 71))
                            {
                                gpa = 3.0;
                            }
                            else
                                if ((p_age < 72) && (p_age > 65))
                                {
                                    gpa = 2.5;
                                }
                                else
                                    if ((p_age < 66) && (p_age > 59))
                                    {
                                        gpa = 2.0;
                                    }
                                    else
                                        if ((p_age < 60) && (p_age > 49))
                                        {
                                            gpa = 1.5;
                                        }
                                        else
                                        {
                                            gpa = 0.0;
                                        }
                }
                t_gpa = (crdhour[0] * gpa) / t_crdhour[0];
                {
                    Console.WriteLine("your GPA in {0} is {1}\n\n", sub[0], t_gpa);
                }
                tp_gpa += t_gpa;
               
               
            }
                {
                    ta_gpa = tp_gpa / 6;
                    Console.WriteLine("your total GPA of all subject is {0}", ta_gpa);
                }
           
            }
        }
    }


OUTPUT:


No comments:

Post a Comment