Sei sulla pagina 1di 3

AIM

To write a java program to get the marks from the student and find the average and total to print the
personal student details.

ALGORITHM
STEP 1: Start the program.
STEP 2: Define a class personal and declare the required instance variables.
STEP 3: Define a member function get detail to get personal details of the students.
STEP 4: Define a member function print detail to print the personal detail of the student.
STEP 5: Define a class academic that inherit from personal class.
STEP 6: Declare the required instance variables.
STEP 7: Declare a member function get detail and overrid the get detail function in the super
Class.
STEP 8: Declare a member function print detail to print the mark detail of the student and
Override print detail of personal class.
STEP 9: Define a class student and declare the main function.
STEP 10: Declare the variables
STEP 11: Declare the object of academic class.
STEP 12: Get number of students.
STEP 13: Call the member function get details and print details.
STEP 14: Stop the program.

PROGRAM
import java.io.*;
class arrayobject
{
public static void main(String args[])throws IOException
{
String get;
int n,i;
BufferedReader d= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the Number of Students:");
get=d.readLine();
n=Integer.parseInt(get);
Academic a[] = new Academic[10];
for(i=0;i<n;i++)
{
a[i]=new Academic();
System.out.println("Enter the detail of student" +(i+1));
a[i].getdetail();
}
for(i=0;i<n;i++)
a[i].printdetail();
}
}
class personal
{
String name,regno,address,email,phone;
void getdetail()throws IOException

{
BufferedReader b= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the name:");
name=b.readLine();
System.out.println("Enter the regno");
regno=b.readLine();
System.out.println("Enter the address");
address=b.readLine();
System.out.println("Enter the email id");
email=b.readLine();
System.out.println("Enter the phone no");
phone=b.readLine();
}
void printdetail()
{
System.out.println("Personal Detail");
System.out.println("Name:"+name);
System.out.println("Address:"+address);
System.out.println("Email:"+email);
}
}
class Academic extends personal
{
int total,avg,i;
int mark[]=new int[4];
String get;
void getdetail()throws IOException
{
super.getdetail();
int i;
total=0;
BufferedReader d= new BufferedReader(new InputStreamReader(System.in));
for(i=1;i<=3;i++)
{
System.out.println("Enter the marks"+i);
//get=d.readLine();
mark[i]=Integer.parseInt(d.readLine());
total=total+mark[i];
}
avg=total/3;
}
void printdetail()
{
super.printdetail();
System.out.println("Academic Detail");
for(i=1;i<=3;i++)
System.out.println("mark:"+mark[i]);
System.out.println("Total"+total);
System.out.println("Average:"+avg);
}
}

OUTPUT
Enter the Number of Students:2
Enter the detail of student:1
Enter the name:jennifer
Enter the regno:08ca023
Enter the address:coonoor
Enter the email id:jeniii.aj@rediffmail.com
Enter the phone no:9486091772
Enter the marks1:65
Enter the marks2:78
Enter the marks3:76
Enter the detail of student2
Enter the name:tresa
Enter the regno:08ca021
Enter the address:ooty
Enter the email id:tresa@yahoo.com
Enter the phone no:9644565676
Enter the marks1:87
Enter the marks2:56
Enter the marks3:76
Personal Detail
Name:jennifer
Address:coonoor
Email:jeniii.aj@rediffmail
Academic Detail
mark:65
mark:78
mark:76
Total219
Average:73
Personal Detail
Name:tresa
Address:ooty
Email:tresa@yahoo.com
Academic Detail
mark:87
mark:56
mark:76
Total219
Average:73

Potrebbero piacerti anche