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

String buffer class in Java?

String buffer class: String buffer is a peer class of string. While string creates strings of fixed length, string buffer creates strings of flexible length that can be modified in...

Write about NESTING of METHODS in Java?

NESTING OF METHODS : A method of a class can be called only by an object of that class or [class itself in the case of static members] using the dot operator. However there is an e...

Difference Between Overriding & Over Loading in Java?

Difference between overriding & over loading: Method overriding is used to provide a different implementation for the same feature of the software it is code replacement. Method over loading...

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