Advertisement
Osiris1002

12. Trade Commissions

May 15th, 2023
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.34 KB | None | 0 0
  1. package ConditionalStatementsAdvanced;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Trade_Commissions {
  6.     public static void main(String[] args) {
  7.         Scanner scan = new Scanner(System.in);
  8.         String town = scan.nextLine();
  9.         double volume = Double.parseDouble(scan.nextLine());
  10.         double percent = 0;
  11.  
  12.  
  13.         if (town.equals("Sofia") && volume >=0 && volume <= 500 ) {
  14.             percent = volume * 5 / 100;
  15.             System.out.printf("%.2f", percent);
  16.         } else if (town.equals("Sofia") && volume >=500 && volume <= 1000) {
  17.             percent = volume * 7 / 100;
  18.             System.out.printf("%.2f", percent);
  19.         } else if (town.equals("Sofia") && volume >=1000 && volume <= 10000) {
  20.             percent = volume * 8 / 100;
  21.             System.out.printf("%.2f", percent);
  22.         } else if (town.equals("Sofia") && volume > 10000) {
  23.             percent = volume * 12 / 100;
  24.             System.out.printf("%.2f", percent);
  25.         } else if (town.equals("Varna") && volume >=0 && volume <= 500) {
  26.             percent = volume * 4.5 / 100;
  27.             System.out.printf("%.2f", percent);
  28.         } else if (town.equals("Varna") && volume >=500 && volume <= 1000) {
  29.             percent = volume * 7.5 / 100;
  30.             System.out.printf("%.2f", percent);
  31.         } else if (town.equals("Varna") && volume >=1000 && volume <= 10000) {
  32.             percent = volume * 10 / 100;
  33.             System.out.printf("%.2f", percent);
  34.         } else if (town.equals("Varna") && volume > 10000) {
  35.             percent = volume * 13 / 100;
  36.             System.out.printf("%.2f", percent);
  37.         } else if (town.equals("Plovdiv") && volume >=0 && volume <= 500) {
  38.             percent = volume * 5.5 / 100;
  39.             System.out.printf("%.2f", percent);
  40.         } else if (town.equals("Plovdiv") && volume >=500 && volume <= 1000) {
  41.             percent = volume * 8 / 100;
  42.             System.out.printf("%.2f", percent);
  43.         } else if (town.equals("Plovdiv") && volume >=1000 && volume <= 10000) {
  44.             percent = volume * 12 / 100;
  45.             System.out.printf("%.2f", percent);
  46.         } else if (town.equals("Plovdiv") && volume > 10000) {
  47.             percent = volume * 14.5 / 100;
  48.             System.out.printf("%.2f", percent);
  49.         }else {
  50.             System.out.println("error");
  51.         }
  52.  
  53.     }
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement