package farecalc;
import java.io.*;
public class FareCalc {
public static void main (String[] args) throws IOException {
BufferedReader in;
in = new BufferedReader(new InputStreamReader(System.in));
double firstMile = 2.80;
double otherMile = 1.20;
System.out.println("Please insert your total Mileage");
String mileageInput = in.readLine();
double mileage = Integer.parseInt(mileageInput);
double price = firstMile + (otherMile * (mileage - 1));
System.out.println("Your fare is £" + price);
}
}
what it should do is take a mileage and work out a cost to it. e.g. 2miles = £4
it works if its a whole number but not if there is a decimal e.g. 2 works 2.1 doesn't.
can anyone help?
thanks