Computing a fare meter using java (What is wrong with my codes?)
import java.util.Scanner; class Main{ public static void main(String args[]) { Scanner in = new Scanner(System.in); System.out.print("Enter the distance travelled (meters): "); int dist = in.nextInt(); double fare = 2.50; if (dist <= 250) fare = 40; else if (dist <= 450) fare = 40 + 2.50; else if (dist <= 451) fare = 40 + 5; else if (dist <= 700) fare = 40 + 7.50; else if (dist <= 701) fare = 40 + 10; else if (dist <= 900) fare = 40 + 12.50; else if (dist <= 901) fare = 40 + 15; else fare = 40 + 15 + 2.50 ; System.out.println("Total cost = P"+fare+0); } }