import java.util.Scanner;
abstract class Person{
String name, city;
Scanner sc=new Scanner(System.in);
}
class Emp extends Person{
int empcode;
float bsal;
void get()
{
System.out.println("Enter employee name:");
name=sc.nextLine();
System.out.println("Enter city:");
city=sc.nextLine();
System.out.print("Enter employee code:");
empcode=sc.nextInt();
System.out.print("Enter basic salary:");
bsal=sc.nextFloat();
}
void disp()
{
System.out.println("Employee name:"+name);
System.out.println("City:"+city);
System.out.println("Employee Code:"+empcode);
System.out.println("Basic Salary:"+bsal);
}
}
class Stu extends Person{
int roll;
String course;
void get()
{
System.out.println("Enter student name:");
name=sc.nextLine();
System.out.println("Enter city:");
city=sc.nextLine();
System.out.print("Enter course:");
course=sc.nextLine();
System.out.print("Enter roll:");
roll=sc.nextInt();
}
void disp()
{
System.out.println("Student name:"+name);
System.out.println("City:"+city);
System.out.println("Roll:"+roll);
System.out.println("Course:"+course);
}
}
public class Abs{
public static void main(String args[])
{
Emp obj1=new Emp();
Stu obj2=new Stu();
obj1.get();
obj2.get();
obj1.disp();
obj2.disp();
}
}
abstract class Person{
String name, city;
Scanner sc=new Scanner(System.in);
}
class Emp extends Person{
int empcode;
float bsal;
void get()
{
System.out.println("Enter employee name:");
name=sc.nextLine();
System.out.println("Enter city:");
city=sc.nextLine();
System.out.print("Enter employee code:");
empcode=sc.nextInt();
System.out.print("Enter basic salary:");
bsal=sc.nextFloat();
}
void disp()
{
System.out.println("Employee name:"+name);
System.out.println("City:"+city);
System.out.println("Employee Code:"+empcode);
System.out.println("Basic Salary:"+bsal);
}
}
class Stu extends Person{
int roll;
String course;
void get()
{
System.out.println("Enter student name:");
name=sc.nextLine();
System.out.println("Enter city:");
city=sc.nextLine();
System.out.print("Enter course:");
course=sc.nextLine();
System.out.print("Enter roll:");
roll=sc.nextInt();
}
void disp()
{
System.out.println("Student name:"+name);
System.out.println("City:"+city);
System.out.println("Roll:"+roll);
System.out.println("Course:"+course);
}
}
public class Abs{
public static void main(String args[])
{
Emp obj1=new Emp();
Stu obj2=new Stu();
obj1.get();
obj2.get();
obj1.disp();
obj2.disp();
}
}
No comments:
Post a Comment