Computer Science Homework Help
The Lancre coven has started doing foreign consulting. Upon request, one of the witches hops on her broomstick
printReport – invoke getCity to retrieve the user input for the city. Once you have the city, get the distance to it by calling getDistance. Try to open the file (Hint: try-catch, file may not exist, place the file in the right place). Read the file (Hint: you don’t know how many lines are in it, so peak into it before you read; find where months begin – the month starts with a number, not a String, so peak for integers; don’t forget to move the cursor to the next line when you encounter an integer). Keep track of total trips for each month, and all months together (Hint: running totals). Print out a charges for the chosen destination for each month (Hint: a charge for each trip is made up of 2 cents charged for each mile of the total miles for the trip (both directions) plus a $10 consulting fee) as well as a grand total for the whole period. Format your output (Hint: assume number of trips can be in the double digits, consulting fees in the triple digits, mileage and total revenue can have up to 4 digits plus 2 digits precision)