Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. ## 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.

```
/********************************************************
* 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.

2. ## Re: Range Calculator

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.