-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q_24.java
43 lines (42 loc) · 1.01 KB
/
Q_24.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package New;
import java.util.Scanner;
public class Employee {
String firstname = getfname();
String lastname = getlname();
double salary=getsalary();
static Scanner sc = new Scanner(System.in);
public static final String getfname() {
System.out.println("Enter firstname");
return sc.next();
}
public static final String getlname() {
System.out.println("Enter lastname");
return sc.next();
}
public static final double getsalary() {
System.out.println("Enter lastname");
return sc.nextDouble();
}
public void display(){
System.out.println("Firstname , lastname , salary: ");
System.out.println(this.firstname);
System.out.println(this.lastname);
System.out.println(this.salary);
}
public static void main(String args[]){
Employee obj = new Employee();
obj.display();
}
}
/*Output
Enter firstname
Manisha
Enter lastname
Sahu
Enter lastname
50000
Firstname , lastname , salary:
Manisha
Sahu
50000.0
*/