Range Calculator

• March 4th, 2013, 04:28 PM
javanewb002
Range Calculator
I am attempting to create a range calculator that will calculate the amount of fuel needed to reach a destination. I have done what I know so far and just need help finishing up a few sections so that it is in working order. Specifically, I am having the most trouble with calculating the number of gallons and liters and the run-time error.

Code Java:

```  /******************************************************** * This class will calculate the number miles a car * can travel given the number of gallons of fuel, * and the MPG of the car can achieve. * * @author * @version ********************************************************/ /******************************************************* * References and Acknowledgements: * * ********************************************************/ import java.util.Scanner; // needed for keyboard input   public class RangeCalculator { // START class RangeCalculator   /***************************************************** * main method * * @param * @return *****************************************************/   public static void main(String args[]) { // START main method System.out.print("Welcome to the CSCI200 Range Calculator.\n"); // Welcome Message System.out.println(); Scanner user_input = new Scanner(System.in); String destination; System.out.print("Type the name of your destination:"); destination = user_input.next(); String number_of_miles; System.out.print( destination + " is how many miles away?"); number_of_miles = user_input.next();     System.out.print( + "is not valid. I will use 100 for the number of miles."); System.out.println();     // Declarations   Scanner input = new Scanner(System.in); // keyboard input int finalDestination; // Your final destination int numberOfMiles; // # of miles needed to travel (int) final int MPG = 23; // # of miles per gallon final double LITERS_CONVERSION = 3.78541178; // conversion factor for liters double fuelGallons; // # of gallons (double) double fuelLiters; // # of liters (double)   // Instantation finalDestination = destination; numberOfMiles = number_of_miles;       // Prompts and Input     // Action code   // Calculate number of gallons // Calculate number of liters   // Output String distance; System.out.print("\n%s is %d miles away. You will need %.2f gallons, or %.4f liters of fuel.");   } // END main method   } // END class RangeCalculator```

Any help with finishing this code is appreciated! Thank you.
• March 4th, 2013, 04:45 PM
Norm
Re: Range Calculator
Quote:

the run-time error.
If you want help with the error, you need to copy the full text of the error message and pasted it here.