Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- int minCabRange = 0;
- int minBusRange = 20;
- int minTrainRange = 100;
- double baseCabTax = 0.70;
- double dayCabTaxPerKm = 0.79;
- double nightCabTaxPerKm = 0.90;
- double busTaxPerKm = 0.09;
- double trainTaxPerKm = 0.06;
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- int kilometers = scanner.nextInt();
- String tariff = scanner.next();
- double smallest = 0.0;
- if (kilometers < 20) {
- if (tariff.equalsIgnoreCase("day")) {
- smallest = baseCabTax + kilometers * dayCabTaxPerKm;
- }
- if (tariff.equalsIgnoreCase("night")) {
- smallest = baseCabTax + kilometers * nightCabTaxPerKm;
- }
- }
- if (kilometers >= 20 && kilometers < 100) {
- smallest = kilometers * busTaxPerKm;
- }
- if (kilometers >= 100) {
- smallest = kilometers * trainTaxPerKm;
- }
- System.out.print(smallest);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement