-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathChallengeTwo.java
35 lines (24 loc) · 995 Bytes
/
ChallengeTwo.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
import java.util.Scanner;
public class ChallengeTwo {
public static double computeSalary(int hoursPerWeek, double moneyPerHour, boolean hasVacation) {
double salary;
if (hasVacation) {
salary = 50 * hoursPerWeek * moneyPerHour + 1000;
} else {
salary = 50 * hoursPerWeek * moneyPerHour;
}
return salary;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter hours per week: ");
int hoursPerWeek = scanner.nextInt();
System.out.println("Enter money per hour: ");
double moneyPerHour = scanner.nextDouble();
System.out.println("Vacation?");
boolean hasVacation = scanner.nextBoolean();
double salary = computeSalary(hoursPerWeek, moneyPerHour, hasVacation);
System.out.println("The year's salary is: " + salary);
scanner.close();
}
}