-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCable2.java
More file actions
76 lines (70 loc) · 2.74 KB
/
Cable2.java
File metadata and controls
76 lines (70 loc) · 2.74 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import java.util.Scanner;
public class Cable2 {
public static void main( String[] args ) {
Scanner sc = new Scanner (System.in);
System.out.println("Which cable package do you have: A, B, or C? ");
String cpack = sc.next();
// a block
if(cpack.equalsIgnoreCase("a"))
{
System.out.println("Please input how many hours you used. ");
double a1 = sc.nextDouble(); // time
if(a1 <= 10) {
System.out.println("Your bill is $9.95 with 10 hours included. You did not use any additional hours. ");
}
if(a1 > 10) {
double a2 = a1 - 10; //number of hours used
double p1 = a2 * 2; //price of additional hours;
double fp = 19.95 + p1; //total price
if (fp >= 13.95 && fp <= 19.95)
{
double as1 = fp - 13.95;
System.out.println("Your base bill is $9.95 with 10 hours included. You used "
+ a2 + " extra hours totaling $"
+ p1 + " additional, for a final total of $"
+ fp + ". You would save $"
+ as1 + " if you switch to package B. ");
}
if (fp >= 19.95)
{
double as2 = fp - 19.95;
System.out.println("Your base bill is $9.95 with 10 hours included. You used "
+ a2 + " extra hours totaling $"
+ p1 + " additional, for a final total of $"
+ fp + ". You would save $"
+ as2 + " if you switch to package C. ");
}
}
}
// a block
// b block
if(cpack.equalsIgnoreCase("b")) {
System.out.println("Please input how many hours you used. ");
double b1 = sc.nextDouble(); // time
if(b1 <= 20) {
System.out.println("Your bill is $13.95 with 20 hours included. You did not use any additional hours. ");
}
if(b1 > 20)
{
double b2 = b1 - 20; //number of hours used
double p1 = b2 * 1; //price of additional hours;
double fp = 13.95 + p1; //total price
if (fp >= 19.95)
{
double bs2 = fp - 19.95;
System.out.println("Your base bill is $13.95 with 20 hours included. You used "
+ b2 + " extra hours totaling $"
+ p1 + " additional, for a final total of $"
+ fp + ". You would save $"
+ bs2 + " if you switch to package C. ");
}
}
}
// b block
//c block
if(cpack.equalsIgnoreCase("c")) {
System.out.println("Your bill is $19.95. ");
}
//c block
}
}