Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Solve in Java Also make sure to include instructions so that this error doesn't show up. (Error: Could not find or load main class Main
Solve in Java
Also make sure to include instructions so that this error doesn't show up.
(Error: Could not find or load main class Main Caused by: java.lang.ClassNotFoundException: Main)
The problem starts here. PROBLEM DESCRIPTION: ^^^^^^^^^^^^^^^^^^^^ Don't you hate it when disasters happen. The amount of inconvenience that disasters cause is just too much to handle. But people have to stick together and help each other out, that's the only way to ease the burden. However, people also have limitations, while everyone would like to help everyone else, they can only do so much. So, when disaster struck a small town of 847 people these people had to relocate to a nearby big city where they were randomly placed in shelters (that means that the number of people in each shelter can be different). Within the shelter they had to establish a temporary life until things get better. So, each group within one shelter decided that they would take turns purchasing the daily supplies so they can sustain themselves until they get back to their homes. So, they decided that every time they need something purchased from outside they would send one person who would pay for those supplies. But they also decided that once life goes back to normal and they are back to their homes that they all would split the costs incurred within each shelter equally among that particular group. That means that whenever someone goes to buy something they would keep the receipts and a total amount of money spent. Since these people have been through so much, we would like to help them by calculating, given a list of expenses that each of them has incurred, the minimum amount of money that has to change hands so everyone would have paid the same amount of money for the supplies within a 1 cent error. We would like to do this for all the shelters no matter how many people are in it, keep in mind there are 847 people so any number of people can be in the shelter between 2 and 847 really. To make things simpler, no one spent more than $1,000. Also you may assume no more than 20 shelters. It is also possible that some people out of the 847 did not stay in these shelters. To make things easier, we will put all the information about the expenses in a file, this file must be read at the beginning of the program to get access to this information. Here's the format of the file. The number of shelters will be placed on line 1 of the file. Following that, you will have that many lists containing the number of people in the shelter and the expenses each of them incurred while at the shelter. Example: 2 <------ this means there are 2 shelters 3 <------ this means there are 3 people in the first shelter 20.00 <------ this means the first person spent 20 bucks 40.00 <------ this means the second person spent 40 bucks 60.00 <------ this means the third person spent 60 bucks 4 25.00 25.01 13.00 13.01 The output for this program should be the total amount of money that changed hands for each shelter: Shelter 1 amount would be: $20.00 Shelter 2 amount would be: $11.99 What to do: ^^^^^^^^^^^ Write a Java program that reads a file formatted as described above and calculate the minimum amount of money that changes hands. In your implementation, you must declare a class called Shelter, this class must contain all the information that are relevant to a particular shelter and that is the number of people, the amount each paid, and the minimum money that changed hands, it should also contain the following methods: readShelterInfo() computeMinMoney() printMoneyExchanged() So, your main program must only contain these three method calls for each shelter declared in the main program. As a result, you will have two Java programs, a driver program and a Shelter class definition to be used in the driver program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started