Saturday 16 April 2016

Design a class Student with following members:

Roll no., name, marks.
It also contains methods for getting value & displaying value. Implement Multiple Inheritance using Interface which contain Method Discipline marks which adds 5% to the total marks of each student. Display the information of each student.

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

namespace ConsoleApplication7
{
    class Student
    {
        public int rno;
        public string name;
        public int marks;
        public void get()
        {
Console.WriteLine("Enter Roll No. : ");
            rno = int.Parse(Console.ReadLine());
            Console.WriteLine("Enter Name : ");
            name = Console.ReadLine();
            Console.WriteLine("Enter Marks : ");
            marks = int.Parse(Console.ReadLine());
        }
        public void display()
        {
            Console.WriteLine(rno);
            Console.WriteLine(name);
            Console.WriteLine(marks);
        }
    }
    public interface Disclipine
    {
        int d();
    }
    class Cal : Student, Disclipine
    {
        public int d1;
        public int d()
        {
            d1 = marks;
            int d2 = (marks * 5) / 100;
            d1 = marks + d2;
            return d1;
        }
        public void display1()
        {
            Console.WriteLine(d1);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Cal s1 = new Cal();
            s1.get();
            s1.d();
            s1.display();
            s1.display1();
            Console.ReadKey();
        }
    }
}

No comments:

Post a Comment