Advertisement
Guest User

Untitled

a guest
Apr 18th, 2017
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Ex032016Pr02TransportPrice {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         int distance = Integer.parseInt(scanner.nextLine());
  8.         String dayOrNight = scanner.nextLine();
  9.         double cost = 0.0d;
  10.  
  11.         if (distance >= 100) {
  12.             cost = 0.06d * distance;
  13.         } else if (distance >= 20) {
  14.             cost = 0.09d * distance;
  15.         } else if (distance >= 0) {
  16.             if ("day".equalsIgnoreCase(dayOrNight)) {
  17.                 cost = 0.70d + (0.79d * distance);
  18.             } else {
  19.                 cost = 0.70d + (0.9d * distance);
  20.             }
  21.         }
  22.  
  23.         System.out.printf("%.2f", cost);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement