3. Student Program

3.Write a simple program to accept student number,name,marks of 3 subjects. Find the average,total and grade in each subject. And Print the total marks,avg, grade of the student , if he/she got less than 40marks in any subject he/she is failure. 

Code:

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

namespace student
{
    class Program
    {
        static void Main(string[] args)
        {
            int sno, m1, m2, m3;
            double total, avg;
            string sname;
            Console.WriteLine("Enter Student Number");
            sno = int.Parse(Console.ReadLine());
            Console.WriteLine("Enter Student Name");
            sname = Console.ReadLine();
            Console.WriteLine("Enter 3 subject marks of student");
            m1 = int.Parse(Console.ReadLine());
            m2 = int.Parse(Console.ReadLine());
            m3 = int.Parse(Console.ReadLine());
            total = m1 + m2 + m3;
            avg = total / 3;
            Console.WriteLine("grand total :" + total);
            Console.WriteLine("Average Percentage :" + avg);
            if (avg > 60)
            {
                Console.WriteLine("1st class");
            }
            else
            {
                if (avg > 50 && avg < 60)
                {
                    Console.WriteLine("2nd class");
                }
                if (avg > 40 && avg < 50)
                {
                    Console.WriteLine("3rd class");
                }
                else
                    Console.WriteLine("fail");
            }


        }
    }
}
 

No comments:

Post a Comment