daily pastebin goal
74%
SHARE
TWEET

8. Trade Commitions

Alex_Matarov May 16th, 2018 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class TradeComissions {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String town = scanner.nextLine();
  8.         double sales = Double.parseDouble(scanner.nextLine());
  9.         double comission = 0.0;
  10.  
  11.         if (town.equalsIgnoreCase("sofia")|| town.equalsIgnoreCase("varna")|| town.equalsIgnoreCase("plovdiv")) {
  12.  
  13.             if (town.equalsIgnoreCase("sofia")) {
  14.                 if (sales >= 0 && sales <= 500) comission = 0.05;
  15.                 else if (sales > 500 && sales <= 1000) comission = 0.07;
  16.                 else if (sales > 1000 && sales <= 10_000) comission = 0.08;
  17.                 else if (sales > 10_000) comission = 0.12;
  18.                 double result = sales * comission;
  19.                 if (result <= 0){
  20.                     System.out.println("error");
  21.                 }
  22.                 else {
  23.                     System.out.printf("%.2f",result);
  24.                 }
  25.             } else if (town.equalsIgnoreCase("varna")) {
  26.                 if (sales >= 0 && sales <= 500) comission = 0.045;
  27.                 else if (sales > 500 && sales <= 1000) comission = 0.075;
  28.                 else if (sales > 1000 && sales <= 10_000) comission = 0.1;
  29.                 else if (sales > 10_000) comission = 0.13;
  30.                 double result = sales * comission;
  31.                 if (result <= 0){
  32.                     System.out.println("error");
  33.                 }
  34.                 else {
  35.                     System.out.printf("%.2f",result);
  36.                 }
  37.             } else if (town.equalsIgnoreCase("plovdiv")) {
  38.                 if (sales >= 0 && sales <= 500) comission = 0.055;
  39.                 else if (sales > 500 && sales <= 1000) comission = 0.08;
  40.                 else if (sales > 1000 && sales <= 10_000) comission = 0.12;
  41.                 else if (sales > 10_000) comission = 0.145;
  42.                 double result = sales * comission;
  43.                 if (result <= 0){
  44.                     System.out.println("error");
  45.                 }
  46.                 else {
  47.                     System.out.printf("%.2f",result);
  48.                 }
  49.             }
  50.         }
  51.         else System.out.println("error");
  52.  
  53.     }
  54.  
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top