SvetlanPetrova

Trade Commissions SoftUni

Apr 15th, 2021 (edited)
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TradeCommissions {
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.         String city = sc.nextLine();
  7.         double vol = Double.parseDouble(sc.nextLine());
  8.         double com = 0.0;
  9.         if (vol >= 0 && vol <= 500) {
  10.             switch (city) {
  11.                 case "Sofia": com += 0.05;break;
  12.                 case "Varna": com += 0.045;break;
  13.                 case "Plovdiv": com += 0.055;break;
  14.                 default: com = 0.0;
  15.             }
  16.         } else if (vol > 500 && vol <= 1000) {
  17.             switch (city) {
  18.                 case "Sofia": com += 0.07;break;
  19.                 case "Varna": com += 0.075;break;
  20.                 case "Plovdiv": com += 0.08;break;
  21.                 default: com = 0.0;
  22.             }
  23.         } else if (vol > 1000 && vol <= 10000) {
  24.             switch (city) {
  25.                 case "Sofia": com += 0.08;break;
  26.                 case "Varna": com += 0.1;break;
  27.                 case "Plovdiv": com += 0.12;break;
  28.                 default: com = 0.0;
  29.             }
  30.         } else if (vol > 10000) {
  31.             switch (city) {
  32.                 case "Sofia": com += 0.12;break;
  33.                 case "Varna": com += 0.13;break;
  34.                 case "Plovdiv": com += 0.145;break;
  35.                 default: com = 0.0;
  36.             }
  37.         } else {
  38.             com = 0.0;
  39.         }
  40.         if (com > 0) {
  41.             System.out.printf("%.2f", com * vol);
  42.         } else {
  43.             System.out.println("error");
  44.         }
  45.  
  46.     }
  47. }
  48.  
Add Comment
Please, Sign In to add comment