The taxi has a base fee of P40.00 for the first 250 meters. An additional P2.50 is added for every succeeding 200 meters. Compute and print the total fare that you would need to pay
import java.util.Scanner;
public class App {
/**
* The start point of the program
*
* @param args
*
*/
public static void main(String[] args) {
Scanner keyBoard = new Scanner(System.in);
System.out.print("Enter meters: ");
int meters = keyBoard.nextInt();
float totalFare = 0;
if (meters <= 250) {
totalFare = (float) (40.0);
}else {
totalFare = (float) ((float) (40.0)+(((meters-250)/200)*2.50));
}
System.out.println("\nThe total fare that you would need to pay: P"+totalFare);
keyBoard.close();
}
}
Comments
Leave a comment