-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject1_cost.c
More file actions
129 lines (101 loc) · 4.13 KB
/
Copy pathproject1_cost.c
File metadata and controls
129 lines (101 loc) · 4.13 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Name: Hasin Shadab Rahman UID: U87513234
// The program below calculates the cost for a selected package, number of people, and duration for an event
#include <stdio.h>
int main() {
// Display package selection prompt
printf("Please select from three packages: 1, 2, and 3\n");
int pack;
int hours;
int guests;
// Get user input for package selection
printf("Enter package selection:");
scanf("%d", &pack);
if (pack == 1) {
// Package 1 details
printf("Enter hours:");
scanf("%d", &hours);
if (1 <= hours && hours < 5) {
// Validate hours
// Get number of guests
printf("Enter the number of guests: ");
scanf("%d", &guests);
if (5 <= guests && guests <= 20) {
// Validate number of guests
// Calculate and display charge for package 1
// 150 is first hour charge after that user is charged hourly basis and based number of guests
int charge = 150 + ((hours-1)* 100) + (guests * 25);
if (charge >= 595) {
// user can be charged upto 595 even though if the calculated charge is greater than 595
charge = 595;
}
printf("Charge ($): %d\n", charge);
} else {
// Invalid number of guests
printf("Invalid number of guests.");
}
}else {
// Invalid number of hours
printf("Invalid hours.");
}
} else if (pack == 2) {
// Package 2 details
// Get number of hours
printf("Enter hours:");
scanf("%d", &hours);
if (1 <= hours && hours < 5) {
//validate Number of hours
// Gets number of guests
printf("Enter the number of guests:");
scanf("%d", &guests);
if (8 <= guests && guests <= 30) {
// validate number of guest
// Calculates number of charge
// 180 is first hour charge after that user is charged hourly basis and based number of guests
int charge =180 + ((hours-1) * 120) + (guests * 22);
if (charge >= 850) {
// user can be charged upto 850 even though if the calculated charge is greater than 850
charge = 850;
}
printf("Charge ($): %d\n", charge);
} else {
//Inavlids number of gusets
printf("Invalid number of guests.");
}
}else {
// Invalids number of hours
printf("Invalid hours.");
}
} else if (pack == 3) {
// Package 3 details
// Gets the number of hours
printf("Enter hours:");
scanf("%d", &hours);
if (1 <= hours && hours < 5) {
// Validate number of hours
// Gets number of guests
printf("Enter the number of guests:");
scanf("%d", &guests);
if (10 <= guests && guests <= 40) {
// Validate number of guests
// Calculate the charge and display the charge
// 200 is first hour charge after that user is charged hourly basis and based number of guests
int charge =200 + ((hours-1) * 150) + (guests * 20);
if (charge >= 1050) {
// user can be charged upto 1050 even though if the calculated charge is greater than 1050
charge = 1050;
}
printf("Charge ($): %d\n", charge);
} else {
// Invalid number of guests
printf("Invalid number of guests.");
}
}else {
// Invalid number of hours
printf("Invalid hours.");
}
} else {
// Invalid package selection
printf("Invalid selection.");
}
return 0;
}