Ads Top

Single inheritance program using java

Single inheritance ,program, using java,practical,lab,computer

Program to create student marks details using the concept of single inheritance


program

import java.io.*;
class Stud
{
String name;
int rno;
void get(int r,String n)
{
rno=r;
name=n;
}
void put()
{
System.out.pritln("Rollno="+rno);
System.out.pritln("Name="+name);
}
}
class Mark extends Stud 
{
int m1,m2,m3,tot;
void getmark(int a,int b,int c)
{
m1=a;
m2=b;
m3=c;
}
void putmarks()
{
tot=m1+m2+m3;
System.out.printlen("Mark1:"+m1);
System.out.printlen("Mark1:"+m2);
System.out.printlen("Mark1:"+m3);
System.out.printlen("Total:"+tot);
}
}
class SingleInheritance
{
public static void main(String args[]);
DataInputStream did=new DatainputStream(system.in);
mark m=new mark();
int rollno,mrk2,mrk2,mrk3;
String n1;
try
{
System.out.println("Enter the rollno:"):
rollno=integer.parseInt(did.readLine());

System.out.println("Enter the Name:"):
n1=did.readLine();

System.out.println("EnterMark1:"):
mrk1=integer.parseInt(did.readLine());

System.out.println("Enter Mark2:"):
mrk2=integer.parseInt(did.readLine());

System.out.println("EnterMark3:"):
mrk3=integer.parseInt(did=.readLine());

m.get(rollno,n1)
m.getmark(mrk1,mrk2,mrk3);
m.put();
m.putmarks();
}
catch(Excpetion e)
{
System.out.println("Error");
}
}

 Output

Enter the rollno:
1
Enter the name:
jass
Enter mark1:
98
Enter mark2:
96
Enter  mark3:
99

Rollno:1
Name:jass
mark1;98
Mark2:96
Mark3:99
Total:293

No comments:

Touchfeeds. Powered by Blogger.