Marksheet Of Different Dipartments Using Concept Of Inheritance



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

namespace MarksSheet
{
    class computerScience
    {
        public int english, physics, maths, electronics;
        public int totalmarks, percentage;
        public void input()
        {
            Console.WriteLine("Enter Your Marks of English,Physics,Maths and Electronics Respectively :");
            english = Int32.Parse(Console.ReadLine());
            physics = Int32.Parse(Console.ReadLine());
            maths = Int32.Parse(Console.ReadLine());
            electronics = Int32.Parse(Console.ReadLine());

        }
        public void total()
        {
            totalmarks = english + physics + maths + electronics;
            Console.WriteLine("Total Marks are : {0}", totalmarks);
            percentage = (totalmarks * 100) / 500;
            Console.WriteLine("Percentage is : {0}%", percentage);


        }

    }

    class Electronics : computerScience
    {
        public int psychology;
        public void input1()
        {
            Console.WriteLine("Enter Your Marks of Psychology,Physics,Maths and Electronics Respectively :");
            psychology = Int32.Parse(Console.ReadLine());
            physics = Int32.Parse(Console.ReadLine());
            maths = Int32.Parse(Console.ReadLine());
            electronics = Int32.Parse(Console.ReadLine());

        }
        public void total1()
        {
            totalmarks = psychology + physics + maths + electronics;
            Console.WriteLine("Total Marks are : {0}", totalmarks);
            percentage = (totalmarks * 100) / 500;
            Console.WriteLine("Percentage is : {0}%", percentage);


        }
    }

    class civil : Electronics
    {
        public int Drawing;
        public void input2()
        {
            Console.WriteLine("Enter Your Marks of Drawing,Physics,Maths and Electronics Respectively :");
            Drawing = Int32.Parse(Console.ReadLine());
            physics = Int32.Parse(Console.ReadLine());
            maths = Int32.Parse(Console.ReadLine());
            electronics = Int32.Parse(Console.ReadLine());

        }
        public void total2()
        {
            totalmarks = Drawing + physics + maths + electronics;
            Console.WriteLine("Total Marks are : {0}", totalmarks);
            percentage = (totalmarks * 100) / 500;
            Console.WriteLine("Percentage is : {0}%", percentage);


        }
    }
    class BioInformatics : civil
    {
        public int MedicalTheory;
        public void input3()
        {
            Console.WriteLine("Enter Your Marks of MedicalTheory,Physics,Maths and Electronics Respectively :");
            MedicalTheory = Int32.Parse(Console.ReadLine());
            physics = Int32.Parse(Console.ReadLine());
            maths = Int32.Parse(Console.ReadLine());
            electronics = Int32.Parse(Console.ReadLine());

        }
        public void total3()
        {
            totalmarks = MedicalTheory + physics + maths + electronics;
            Console.WriteLine("Total Marks are : {0}", totalmarks);
            percentage = (totalmarks * 100) / 500;
            Console.WriteLine("Percentage is : {0}%", percentage);


        }
    }


    class Program
    {
        static void Main(string[] args)
        {
            BioInformatics obj = new BioInformatics();

            int choice;
            char y,n;
            start:
            Console.WriteLine("Enter Your Desire Choice\n1.Computer Science\n2.Electonics\n3.Civil\n4.BioImformatics\n5.Exit ");
            choice = Int16.Parse(Console.ReadLine());
            if (choice == 1)
            {
                obj.input();
                obj.total();
            }
            else if (choice == 2)
            {
                obj.input1();
                obj.total1();
            }
            else if (choice == 3)
            {
                obj.input2();
                obj.total2();
            }
            else if (choice == 4)
            {
                obj.input3();
                obj.total3();
            }
            else if (choice == 5)
            {
                System.Environment.Exit(0);
            }
            else
            {
                Console.WriteLine("Invalid Choice \n");
            }
            Console.ReadLine();
           // Console.WriteLine("Do You Want To Continue....?Y/N");
           //do
           //{
           //    goto start;
           //}

            goto start;
            

        }
    }
}

Output

 

No comments:

Post a Comment