WRITE A PROGRAM THAT STORES THE DETAILS OF STUDENT AND EMPLOYEES .THE STUDENT DETAILS INCLUDE FIRST NAME,LAST NAME,AGE,COURSE ENROLLED, AND STUDENT ID. THE EMPLOYEE DETAILS INCLUDE FIRST NAME,LAST NAME,AGE,SALARY,DEPARTMENT NAME,DESIGNATION,AND EMPLOYEEID. YOU NEED TO IMPLEMENT THE PRECEDING FUNCTIONALITIES BY ENSURING THE REUSABILITY OF CODE.
ANSWER
public class persondetails {
String firstname;
String lastname;
int age;
public void showdetails() {
system.out.println("\nThe student details are: \n");
system.out.println("first name: " + super.firstname);
system.out.println("last name: " + super.lastname);
system.out.println("age: " + super.age);
system.out.println("course enrolled: + + stream);
system.out.println("student id: " + studentid);
}
}
public class employeedetails extends persondetails {
double salary;
string desg;
string dept;
public void getdetail(string name1, int age, double sal, string des, string dep) {
super . getdetail (name1,name2,age);
salary = sal;
desg = des;
dept = dep;
showdetail ();
}
public void showdetail () {
system.out.println("\nthe employee details are : \n");
system.out.println(" first name: " + super. firstname);
system.out.println("age: " + super.age);
system.out.println("{departmment: " + dept);
system.out.println("designation: " + desg);
system.out.println("salary: " + salary);
}
}
public class main details {
public static void main (string [] args) {
studentdetails sobj = new studentdetails ();
sobj.getdetail("peter", "parker", 23 , "science", 125);
employeedetails eobj = new employeedetails ();
eobj.getdetail("david", "henson", 34, 2000, "manager", "admin");
}
}
ANSWER
public class persondetails {
String firstname;
String lastname;
int age;
public void showdetails() {
system.out.println("\nThe student details are: \n");
system.out.println("first name: " + super.firstname);
system.out.println("last name: " + super.lastname);
system.out.println("age: " + super.age);
system.out.println("course enrolled: + + stream);
system.out.println("student id: " + studentid);
}
}
public class employeedetails extends persondetails {
double salary;
string desg;
string dept;
public void getdetail(string name1, int age, double sal, string des, string dep) {
super . getdetail (name1,name2,age);
salary = sal;
desg = des;
dept = dep;
showdetail ();
}
public void showdetail () {
system.out.println("\nthe employee details are : \n");
system.out.println(" first name: " + super. firstname);
system.out.println("age: " + super.age);
system.out.println("{departmment: " + dept);
system.out.println("designation: " + desg);
system.out.println("salary: " + salary);
}
}
public class main details {
public static void main (string [] args) {
studentdetails sobj = new studentdetails ();
sobj.getdetail("peter", "parker", 23 , "science", 125);
employeedetails eobj = new employeedetails ();
eobj.getdetail("david", "henson", 34, 2000, "manager", "admin");
}
}
No comments:
Post a Comment