-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSalary.java
38 lines (38 loc) · 1.54 KB
/
Salary.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
// ***************************************************************
// Salary.java
// Computes the raise and new salary for an employee
// ***************************************************************
import java.util.Scanner;
public class Salary
{
public static void main (String[] args)
{
Scanner input = new Scanner(System.in);
// Get the current salary and performance rating
System.out.print("Enter the current salary: $");
double currentSalary = input.nextDouble();
System.out.print ("Enter the performance rating: ");
double rating = input.nextDouble();
// Compute the raise -- Use if ... else ...
// Print the results
if (rating == 1)
{
double raise = (int)((currentSalary * 1.06) * 100)/100.0;
System.out.println("Amount of your raise: $" + (int)((currentSalary * .06) * 100)/100.0);
System.out.println("Your new salary: $" + raise);
}
else if (rating == 2)
{
double raise = (int)((currentSalary * 1.04) * 100)/100.0;
System.out.println("Amount of your raise: $" + (int)((currentSalary * .04) * 100)/100.0);
System.out.println("Your new salary: $" + raise);
}
else if (rating == 3)
{
double raise = (int)((currentSalary * 1.015) * 100)/100.0;
System.out.println("Amount of your raise: $" + (int)((currentSalary * .015) * 100)/100.0);
System.out.println("Your new salary: $" + raise);
}
input.close();
}
}