Guest User

Untitled

a guest
Nov 5th, 2017
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.52 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class exam3 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double teg = Double.parseDouble(scanner.nextLine());
  8.         String tip = scanner.nextLine();
  9.         double distance = Double.parseDouble(scanner.nextLine());
  10.  
  11.         double price = 0;
  12.         double sum = 0;
  13.         double percent = 0;
  14.  
  15.         if (teg >= 1 && teg <= 10) {
  16.             price = 0.05;
  17.  
  18.             if (tip.equals("express")) {
  19.                 percent = (price * 0.40);
  20.             }
  21.  
  22.         } else if (teg > 11 && teg <= 40) {
  23.             price = 0.10;
  24.  
  25.             if (tip.equals("express")) {
  26.                 percent = (price * 0.05);
  27.  
  28.             }
  29.  
  30.         } else if (teg > 41 && teg <= 90) {
  31.             price = 0.15;
  32.  
  33.             if (tip.equals("express")) {
  34.                 percent = (price * 0.02);
  35.  
  36.             }
  37.         } else if (teg > 91 && teg <= 150) {
  38.             price = 0.20;
  39.             if (tip.equals("express")) {
  40.                 percent = (price * 0.01);
  41.  
  42.             }
  43.  
  44.         } else if (teg < 1) {
  45.             price = 0.03;
  46.             if (tip.equals("express")) {
  47.                 percent = (price * 0.80);
  48.  
  49.             }
  50.  
  51.  
  52.         }
  53.         sum = price * distance;
  54.         double res = teg * percent;
  55.         double result = res * distance;
  56.         double total = result + sum;
  57.  
  58.         System.out.printf("The delivery of your shipment with weight of %.3f kg. would cost %.2f lv.", teg, total);
  59.  
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment