Advertisement
kallyy7

Untitled

Mar 2nd, 2018
1,305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.72 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class CourierExpress {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.  
  7.         double weight = Double.parseDouble(console.nextLine());
  8.         String typeCourier = console.nextLine();
  9.         int distance = Integer.parseInt(console.nextLine());
  10.  
  11.         double allPrice = 0.0;
  12.  
  13.  
  14.         if (typeCourier.equals("standard")){
  15.             if (weight < 1){
  16.                 allPrice = distance * 0.03;
  17.             } else if (weight >=1 && weight <=10){
  18.                 allPrice = distance * 0.05;
  19.             } else if (weight >=11 && weight <=40){
  20.                 allPrice = distance * 0.10;
  21.             } else if (weight >= 41 && weight <=90){
  22.                 allPrice = distance *0.15;
  23.             } else if (weight >= 91 && weight <=150){
  24.                 allPrice = distance * 0.20;
  25.             }
  26.         } else if (typeCourier.equals("express")){
  27.             if (weight < 1){
  28.                 allPrice = distance * 0.03 + 0.03 * 0.8 * weight * distance;
  29.             } else if (weight >=1 && weight <=10){
  30.                  allPrice = distance * 0.05 + 0.05 * 0.4 * weight * distance;
  31.             } else if (weight >=11 && weight <=40){
  32.                  allPrice = distance * 0.10 + 0.10 * 0.05 * weight * distance;
  33.             } else if (weight >=41 && weight <=90){
  34.                  allPrice = distance * 0.15 + 0.15 * 0.02 * weight * distance;
  35.  
  36.             } else if (weight >=91 && weight <=150){
  37.                  allPrice = distance * 0.20 + 0.20 * 0.01 * weight * distance;
  38.  
  39.             }
  40.         }
  41.         System.out.printf("The delivery of your shipment with weight of %.3f kg. would cost %.2f lv.",weight,allPrice);
  42.  
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement