rossirm

03.Courier Express - Задача 3. Куриер Експрес

Nov 6th, 2017
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.16 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class p03 {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner scan = new Scanner(System.in);
  7.         double weight = Double.parseDouble(scan.nextLine());
  8.         String type = scan.nextLine().toLowerCase();
  9.         int distance = Integer.parseInt(scan.nextLine());
  10.         double pricePerKilometer = 0.0;
  11.         double result = 0.0;
  12.         double result1 = 0.0;
  13.         double up = 0.0;
  14.         double up2 = 0.0;
  15.         double up3 = 0.0;
  16.  
  17.         if (type.equals("standard")) {
  18.             if (weight < 1.0) {
  19.                 pricePerKilometer = 0.03;
  20.                 result = distance * pricePerKilometer;
  21.                 System.out.printf("The delivery of your shipment with weight of %.3f kg. would cost %.2f lv.", weight, result);
  22.             } else if (weight >= 1 && weight <= 10) {
  23.                 pricePerKilometer = 0.05;
  24.                 result = distance * pricePerKilometer;
  25.                 System.out.printf("The delivery of your shipment with weight of %.3f kg. would cost %.2f lv.", weight, result);
  26.             } else if (weight >= 11 && weight <= 40) {
  27.                 pricePerKilometer = 0.10;
  28.                 result = distance * pricePerKilometer;
  29.                 System.out.printf("The delivery of your shipment with weight of %.3f kg. would cost %.2f lv.", weight, result);
  30.             } else if (weight >= 41 && weight <= 90) {
  31.                 pricePerKilometer = 0.15;
  32.                 result = distance * pricePerKilometer;
  33.                 System.out.printf("The delivery of your shipment with weight of %.3f kg. would cost %.2f lv.", weight, result);
  34.             } else if (weight >= 91 && weight <= 150) {
  35.                 pricePerKilometer = 0.20;
  36.                 result = distance * pricePerKilometer;
  37.                 System.out.printf("The delivery of your shipment with weight of %.3f kg. would cost %.2f lv.", weight, result);
  38.             }
  39.         } else if (type.equals("express")) {
  40.             if (weight < 1.0) {
  41.                 pricePerKilometer = 0.03;
  42.                 result1 = distance * pricePerKilometer;
  43.                 up = 0.80 * pricePerKilometer;
  44.                 up2 = distance * up;
  45.                 up3 = weight * up2;
  46.                 result = result1 + up3;
  47.                 System.out.printf("The delivery of your shipment with weight of %.3f kg. would cost %.2f lv.", weight, result);
  48.             } else if (weight >= 1 && weight <= 10) {
  49.                 pricePerKilometer = 0.05;
  50.                 result1 = distance * pricePerKilometer;
  51.                 up = 0.40 * pricePerKilometer;
  52.                 up2 = distance * up;
  53.                 up3 = weight * up2;
  54.                 result = result1 + up3;
  55.                 System.out.printf("The delivery of your shipment with weight of %.3f kg. would cost %.2f lv.", weight, result);
  56.             } else if (weight >= 11 && weight <= 40) {
  57.                 pricePerKilometer = 0.10;
  58.                 result1 = distance * pricePerKilometer;
  59.                 up = 0.05 * pricePerKilometer;
  60.                 up2 = distance * up;
  61.                 up3 = weight * up2;
  62.                 result = result1 + up3;
  63.                 System.out.printf("The delivery of your shipment with weight of %.3f kg. would cost %.2f lv.", weight, result);
  64.             } else if (weight >= 41 && weight <= 90) {
  65.                 pricePerKilometer = 0.15;
  66.                 result1 = distance * pricePerKilometer;
  67.                 up = 0.02 * pricePerKilometer;
  68.                 up2 = distance * up;
  69.                 up3 = weight * up2;
  70.                 result = result1 + up3;
  71.                 System.out.printf("The delivery of your shipment with weight of %.3f kg. would cost %.2f lv.", weight, result);
  72.             } else if (weight >= 91 && weight <= 150) {
  73.                 pricePerKilometer = 0.20;
  74.                 result1 = distance * pricePerKilometer;
  75.                 up = 0.01 * pricePerKilometer;
  76.                 up2 = distance * up;
  77.                 up3 = weight * up2;
  78.                 result = result1 + up3;
  79.                 System.out.printf("The delivery of your shipment with weight of %.3f kg. would cost %.2f lv.", weight, result);
  80.             }
  81.         }
  82.     }
  83. }
Add Comment
Please, Sign In to add comment