AsyaDamyanova

Trade Commissions

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