A hotel keeps records of its sales in a text file (called "hotel.txt"; provided in the MOODLE). Each line contains the following information separated by semicolons (“:"): The client's name, the...


A hotel keeps records of its sales in a text file (called

Extracted text: A hotel keeps records of its sales in a text file (called "hotel.txt"; provided in the MOODLE). Each line contains the following information separated by semicolons (“:"): The client's name, the service sold (such as Dining, conference...), and the amount of the sale. Figure 2 shows a few lines of input file. Write a program that reads such a file and displays the total and average amount for each service category. Knowing that there are four services (Dining, Lodging, Conference, and Parking). Display an error using the proper exception if: The file does not open/exist The format of the data in the file is incorrect (e.g. sale amount = "230;9" or "12ab") Dividing by zero (when computing average) Make sure you close any open files even if an error occurs. Benjamin Bayer:Dining:26.5 English Joyce A:Lodging:120.14 Zalaya:Lodging:173.6 Chung-cha kim:Conference:425 Service Total Average Dining Lodging 220.8 44.16 544.0 181,35 Conference 425.0 425.00 Dividing by Zero, this hotel service not used Figure 2a input file sample exe2 Figure 2b Output sample exe2 Optional: Try to resolve the division by zero error so the output becomes as shown in figure 2c ***** ***** Service Total Average Dining Lodging Conference 425.0 425.00 Parking 220.8 44.16 544.0 181.35 0.0 0,00 Figure 2e Output Sample2 exe2 Benjamin Bayer:Dining:26.5 English Joyce A:Lodging:120.14 Zalaya:Lodging:173.6 Chung-cha kim:Conference:425 Davidson:Dining:15.6 Rohan Panchal:Dining:36.9 Barbara Benson:Dining:45.8 Smith John B:Lodging:250.3 Wong, Fanklin:Dining:96 (Hotel text file )
Jun 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here