Repository navigation
Expand file tree
/
Copy pathMain.java
More file actions
103 lines (93 loc) · 3.04 KB
/
Copy pathMain.java
File metadata and controls
103 lines (93 loc) · 3.04 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import java.util.Formatter;
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Golf Package Menu:\n\tRO [Room only]\n\tRM [Room plus meals]\n\tSP [Stay and play]\n\nEnter the menu choice: ");
String pack = scan.nextLine();
//declare and assign values to any additional variables you will need to store data in your program
double totalPrice = 0.00;
int golfRounds;
int persons;
switch(pack)
{
case "SP":
System.out.print("Enter the number of rounds of golf: ");
golfRounds = scan.nextInt();
//should prompt/scan for number of golf rounds
totalPrice += getGolfPrice(golfRounds);
//should call getGolfPrice(golfRounds); and update totalPrice
case "RM":
System.out.print("Enter the number of persons staying in the room: ");
persons = scan.nextInt();
//should prompt/scan for number of people staying in the room
totalPrice += getPersonPrice(pack, persons);
//should call getPersonPrice(pack, persons); and update totalPrice
case "RO":
totalPrice += getRoomPrice(pack);
//should call getRoomPrice(pack); and update totalPrice
Formatter formatter = new Formatter();
formatter.format("%.2f", totalPrice);
System.out.print("\nThe package cost is $" + formatter.toString());
//Should print "The package cost is $" + totalPrice
break;
default:
System.out.println("\nERROR: This package is unknown");
}
}
public static double getPersonPrice(String selection, int persons)
{
double personPrice = 0.00;
//declare and assign values to any additional variables you will need to store data in your program
switch(selection)
{
case "SP":
personPrice = (persons*135.25);
return personPrice;
case "RM":
personPrice = (persons*145.5);
return personPrice;
default:
return 0.00;
}
}
public static double getRoomPrice(String selection)
{
double roomPrice = 0.00;
//declare and assign values to any additional variables you will need to store data in your program
switch(selection)
{
case "SP":
roomPrice = 224.95;
return roomPrice;
case "RM":
roomPrice = 249.95;
return roomPrice;
case "RO":
roomPrice = 264.95;
return roomPrice;
default:
return 0.00;
}
}
public static double getGolfPrice(int golfRounds)
{
double golfPrice = 0.00;
//declare and assign values to any additional variables you will need to store data in your program
switch(golfRounds)
{
case 0:
break;
case 1:
golfPrice = 115.40;
return golfPrice;
case 2:
golfPrice = 230.80;
return golfPrice;
default:
golfPrice = (golfRounds-2)*95.40 + 230.80;
return golfPrice;
}
return 0.00;
}
}