The Lancre coven has started doing foreign consulting Upon request one of the witches hops on her broomstick

Question

  • getCity – the method takes one word user input (from the keyboard, Hint: Scanner) and continues asking the user to correct himself until the city is valid (Hint: loop). Validate the city by calling checkValidCity. Pass the value of the city back to the method, which invokes getCity.
  • 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 consuing 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, consuing fees in the triple digits, mileage and total revenue can have up to 4 digits plus 2 digits precision)

    Java Programming