-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q_25.java
39 lines (36 loc) · 866 Bytes
/
Q_25.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
package New;
import java.util.Scanner;
public class EmployeeTest {
double salary=getMonthlySalary();
double yearlySalary=getYearlySalary();
static Scanner sc = new Scanner(System.in);
public static final double getMonthlySalary() {
System.out.println("Enter monthly salary");
return sc.nextDouble();
}
public double getYearlySalary()
{
double yearlySalary = salary * 12.0;
return yearlySalary;
}
public void display(){
System.out.println("Yearly salary: ");
System.out.println(this.yearlySalary);
}
public static void main(String args[]){
EmployeeTest obj1 = new EmployeeTest();
obj1.display();
EmployeeTest obj2=new EmployeeTest();
obj2.display();
}
}
/*Output
Enter monthly salary
100
Yearly salary:
1200.0
Enter monthly salary
200
Yearly salary:
2400.0
*/