PROGRAM TO CALCULATE TOT, AVG AN D GRADE USING MULTILEVEL INHERITENCE

import java.util.*; class Adm {              int rno;              String name;             void getData(int x,String y)      ...

import java.util.*;
class Adm
{
             int rno;
             String name;
            void getData(int x,String y)
            {
                        rno=x;
                         name=y;
            }
            void putData()
            {
                          System.out.println("ROLL NO IS"+rno);
                          System.out.println("NAME IS"+name);
            }
}
class marks extends Adm
{
              float m1,m2,m3;
              void getMarks(int x,int y,int z)
                        {
                                      m1=x;
                                      m2=y;
                                      m3=z;
                        }
                        void putMarks()
                        {
System.out.println("MARKS OBTAINED"+m1+" "+m2+" "+m3);
                        }
}
class Grade extends marks
{
                                    float tot,avg;
                                    char g;
                                    void getGrade()
                                    {
                                      tot=m1+m2+m3;
                                      avg=tot/3;
                                      if(avg>=60)
                                      g=1;
                                    else
                                      g=2;
                                    }
                                    void putGrade()
                                    {
                                                  putData();
                                                  putMarks();
                                                  System.out.println("TOTAL IS"+tot);
                                                  System.out.println("AVERGE IS"+avg);
                                                  System.out.println("GRADE IS"+g);
                                    }
}
class Admin
{
                        public static void main(String args[])
                        {
                                      Grade obj=new Grade();
                                      obj.getData(102,"BOSS");
                                      obj.getMarks(70,80,90);
                                      obj.getGrade();
                                      obj.putGrade();
                        }
}


OUTPUT:


ROLL NO IS102

NAME ISBOSS

MARKS OBTAINED
70.0 80.0 90.0

TOTAL IS240.0

AVERGE IS80.0

GRADE IS 1


Related

Differences Between Applets and Standalone Programs?

Differences  Between   Applets  and   stand alone  programs : Although  both  the  applets   is  stand  alone  applicati...

How to Design a Web Page?

Designing  a   web  page  : Java  applets  are  program  that  reside  one  web page.  In  order  to r...

Finalizer Method in Java

FINALIZER METHODS: We have seen that a constructor method is used to initialize an object when it is declared. This process is known as initialization. similarly,java supports a concept called fi...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item