-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDistanceLearning.java
More file actions
26 lines (26 loc) · 855 Bytes
/
DistanceLearning.java
File metadata and controls
26 lines (26 loc) · 855 Bytes
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
/**
* QUESTION TWO
* program to evaluate cost of distance learning
*/
import java.util.Scanner;
public class DistanceLearning {
public static void main(String args[]) {
Scanner keypad = new Scanner(System.in);
while(true){
try{
System.out.print("\n Enter Hours: ");//PROMPT FOR HOURS
int hours = keypad.nextInt();//TAKE THE VALUE FOR HOURS
if(hours <= 0){break;}//CHECK THAT HOURS IS GREATER THAN 0
double cost = 0;
if(hours <= 15){
cost += hours * 500;
}else{
cost += hours * 445;
}
System.out.print("\n Total cost: " + cost + "\n");//PRINT COST
}catch(Exception e){
break;
}
}
}
}