INTRO JAVA A hotel salesperson enters sales in a text file. Each line contains the following, separated by semicolons: The name of the client, the service sold (such as Dinner, Conference, Lodging, and so on), the amount of the sale, and the date of that event. Write a program that (a) reads input file and displays the total amount for each service category. (b) writes a separate file for each service category, containing the entries for that category ; the file name should be ; so if the input has Dinner and Conference as service categories, the output file will be Dinner.txt and Conference.txt Note: Display an error if the file does not exist or the format is incorrect. Create your own input file using the format described above, here are few lines from the input file: John Doe; Dinner; 45.69;04/19/2020 Sean Kim; Conference; 1000.00; 05/03/2021 Mike Jones;Conference;750.00;05/01/2021 Jane Smith;Dinner;50.00;04/19/2021 The program should generate the following outputs (if the input file contains the lines from above) 1. Display total amount per category Dinner: 95.69 Conference: 1750.00 2. File for each service category Dinner.txt John Doe; Dinner; 45.69;04/19/2020 Jane Smith;Dinner;50.00;04/19/2021 Conference.txt Sean Kim; Conference; 1000.00; 05/03/2021 Mike Jones;Conference;750.00;05/01/2021 Note: Don't hardcode service categories i.e. the program should support dynamic number of categories.
INTRO JAVA A hotel salesperson enters sales in a text file. Each line contains the following, separated by semicolons: The name of the client, the service sold (such as Dinner, Conference, Lodging, and so on), the amount of the sale, and the date of that event. Write a program that (a) reads input file and displays the total amount for each service category. (b) writes a separate file for each service category, containing the entries for that category ; the file name should be <ServiceCategory.txt> ; so if the input has Dinner and Conference as service categories, the output file will be Dinner.txt and Conference.txt Note: Display an error if the file does not exist or the format is incorrect. Create your own input file using the format described above, here are few lines from the input file: John Doe; Dinner; 45.69;04/19/2020 Sean Kim; Conference; 1000.00; 05/03/2021 Mike Jones;Conference;750.00;05/01/2021 Jane Smith;Dinner;50.00;04/19/2021
The program should generate the following outputs (if the input file contains the lines from above) 1. Display total amount per category Dinner: 95.69 Conference: 1750.00 2. File for each service category Dinner.txt John Doe; Dinner; 45.69;04/19/2020 Jane Smith;Dinner;50.00;04/19/2021 Conference.txt Sean Kim; Conference; 1000.00; 05/03/2021 Mike Jones;Conference;750.00;05/01/2021
Note: Don't hardcode service categories i.e. the program should support dynamic number of categories. |
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images