-
Notifications
You must be signed in to change notification settings - Fork 0
/
HotelBillingSystemProject.java
191 lines (125 loc) · 6.4 KB
/
HotelBillingSystemProject.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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
package javapractices;
import java.io.*;
import java.text.ParseException;
//import java.time.format.DateTimeFormatter;
import java.time.LocalDate;
import java.time.chrono.ChronoLocalDate;
//import java.time.format.ResolverStyle;
import java.time.temporal.ChronoUnit;
import java.util.Scanner;
//import java.util.concurrent.TimeUnit;
public class HotelBillingSystemProject {
public static void main(String[] args) throws ParseException {
Scanner sce = new Scanner(System.in);
File file = new File("bills.txt");
try (PrintWriter writer = new PrintWriter(new FileWriter(file, true))) {
System.out.println("Welcome!");
System.out.println("Enter the number of customers checked in: " );
int noOfCustomers=sce.nextInt();
if(noOfCustomers <1)
{
System.out.println("Enter a valid number");
}
else
{
for(int i=0;i<noOfCustomers;i++)
{
System.out.println("Welcome to the Billing Counter !");
sce.nextLine();
System.out.print("Enter name of customer : ");
String name = sce.nextLine();
sce.nextLine();
writer.println("Customer Name: " + name);
System.out.println(" ");
System.out.println("Choose the room type: ");
System.out.println("1: Deluxe room");
System.out.println("2: Super Deluxe room");
System.out.println("3: Premium Suite");
int numberofRoom=sce.nextInt();
switch(numberofRoom)
{
case 1: System.out.println("Room type: Deluxe Room");
break;
case 2: System.out.println("Room type: Super Deluxe Room");
break;
case 3: System.out.println("Room type: Premium Suite");
break;
}
/* System.out.print("Enter name of customer : ");
String name = sce.nextLine();
sce.nextLine();
writer.println("Customer Name: " + name);*/
System.out.println(" ");
sce.nextLine();
System.out.print("Enter room number: ");
String room = sce.nextLine();
writer.println("Room Number: " + room);
sce.nextLine();
System.out.println(" ");
/* System.out.print("Enter number of days stayed: ");
int days = sce.nextInt();
writer.println("Days Stayed: " + days);
sce.nextLine();
System.out.println(" ");*/
//Amenities used
// Additional charges
int extraBedCharge = 200;
int wifiCharge = 50;
int mealCharge = 200;
int poolCharge = 150;
//input validation
boolean mealsAdded;
boolean poolAdded;
boolean wifiEnabled;
boolean extrabedReq;
ChronoLocalDate checkInDate;
ChronoLocalDate checkOutDate;
System.out.print("Check-in Date (yyyy-mm-dd): ");
checkInDate = LocalDate.parse(sce.next());
System.out.print("Check-out Date (yyyy-mm-dd): ");
checkOutDate = LocalDate.parse(sce.next());
if(checkOutDate.isBefore(checkInDate)) {
System.out.println("Error: Invalid check-out date. Please enter a date after the check-in date.");
return;
}
//System.out.print(" number of days stayed: ");
long days=ChronoUnit.DAYS.between(checkInDate, checkOutDate);
System.out.println ("Number of Days Stayed: " + days);
switch(numberofRoom)
{
case 1: System.out.println("Room rate: Rs.900 per night ");
double total = days * 900;
writer.println("Total Bill: " + total);
System.out.printf("Total bill for " +name+ " is Rs.%.2f\n", total);
break;
case 2: System.out.println("Room rate: Rs.1500 per night");
double total1 = days * 1500;
writer.println("Total Bill: " + total1);
System.out.printf("Total bill for " +name+ " is Rs.%.2f\n", total1);
break;
case 3: System.out.println("Room rate: Rs.3000 per night");
double total2 = days * 3000;
writer.println("Total Bill: " + total2);
System.out.printf("Total bill for " +name+ " is Rs.%.2f\n", total2);
break;
}
//System.out.printf("Total bill for " +name+ " is Rs.%.2f\n", total);
/*
System.out.println("");
System.out.print("Enter rate of room for one day: ");
double rate = sce.nextDouble();
writer.println("Room Rate: " + rate);*/
System.out.println(" ");
/* double total = days * rate;
writer.println("Total Bill: " + total);
System.out.printf("Total bill for " +name+ " is Rs.%.2f\n", total);*/
System.out.println(" ");
System.out.println("*********************************************************");
}
}
}
catch (IOException e) {
System.out.println("Error writing to file: " + e.getMessage());
}
}
}