Untitled
unknown
plain_text
2 years ago
2.0 kB
11
Indexable
import java.util.Scanner;
class employee
{
int age,salary;
long phone_number;
String name;
String address;
public void read()
{
Scanner scan = new Scanner(System.in);
System.out.println("Enter the name");
name = scan.nextLine();
System.out.println("Enter the address");
address = scan.nextLine();
System.out.println("Enter the age");
age = scan.nextInt();
System.out.println("Enter the phone number");
phone_number = scan.nextLong();
System.out.println("Enter the salary");
salary = scan.nextInt();
}
public void Print_Salary()
{
System.out.println("Salary is: "+salary);
}
}
class officer extends employee
{
String specialization;
Scanner scan1 = new Scanner(System.in);
public void spe()
{
System.out.println("Enter the specialization");
specialization = scan1.nextLine();
}
}
class officer extends employee
{
String specialization;
Scanner scan1 = new Scanner(System.in);
public void spe()
{
System.out.println("Enter the specialization");
specialization = scan1.nextLine();
}
}
public class Main
{
public static void main(String s[])
{
officer o = new officer();
manager m = new manager();
o.read();
o.spe();
System.out.println("\nName : "+o.name+"\nAge : "+o.age+"\nPhone Number :"+o.phone_number+"\nAddress :"+o.address);
o.Print_Salary();
System.out.println("Specialization : "+o.specialization);
System.out.println("\n\n");
m.read();
m.dep();
System.out.println("\nName : "+m.name+"\nAge : "+m.age+"\nPhone Number :"+m.phone_number+"\nAddress :"+m.address);
m.Print_Salary();
System.out.println("Department : "+m.department);
}
}Editor is loading...