Html/javascript

Java program to demonstarte single inheritance |Java-inheritance :Education notes for study

Java program to demonstarte single inheritance |Java-inheritance :Education notes for study 




import java.io.DataInputStream;

import java.io.IOException;

{

int regno,m1,m2,m3;

String name;

DataInputStream obj=new DataInputStream(System.in);


void getdata () throws IOException

{

Sustem.out.println ("\n**********");


System.out.println ("enter student information ");


System.out.println  ("*************");


System.out.println("enter registration number:");


regno=Integer.parseInt(obj.readLine ());


System.out.print("enter name:");

name=obj.readLine ();


System.out.println("\n enter marks for 3 subject(out of 100)");

System.out.print("enter marks for java:");

m1=Integer.parseInt(obj.readLine));


System.out.print  ("enter the marks for software engineering :");


m2=Integer.parseInt(obj.readLine));


System.out.print("enter marks for system programming:");


m3=Integer.parseInt(obj.readLine));

}


void  display()

{

System.out.println("\n\n**************");

System.out.println("student details");

System.out.println("*************");

System.out.println("\n registeration number:"+regno);


System.out.println(Name:"+name);

System.out.println("\n marks  scored by"+name);


System.out.println("java:"+m1);

System.out.println("software engineering:"+m2);


System.out.println("system programming:"+m3);


}

}


class calculate extends student

{

float  total;

double percent;

void  compute ()

{

total=m1+m2+m3;

percent=(total/300)*100;

}


void show ()

{

System.out.println("\n total:"+total);

System.out.println("percentage:"+percent);

}

}


class single

{

public static void main(String args [])throwsIOException

{

calculate c1=new calculate ();

c1.getdata ();

c1.display ();

c1.compute ();

c1.show ();

}

}



Output:-

******************

Enter student Information 

***********************

Enter Registration Number:326

Enter Name:charles

Enter marks for 3 subjects (out of 100)

Enter marks for Java:85

Enter marks for software engineering:90

Enter marks for system programming:95

*****************************

Student details 

*************************

Registration Number:304

Name:charles

marks scored by charles

Java:85

Software Engineering:90

System programming:95

Total:270.0

Percentage:90.0






Read my previous article: Display Fibonacci series upto n terms :-

https://getnotesforstudy.blogspot.com/2022/07/java-program-to-find-fibonacci-series.html



Post a Comment

0 Comments