Advertisement
ver4oni

TaxCalculator

Dec 15th, 2019
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.32 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TaxCalculator {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int powerEngine = Integer.parseInt(scanner.nextLine());
  8.         String city = scanner.nextLine();
  9.         String standart =scanner.nextLine();
  10.         double tax = 0;
  11.         double discount = 0;
  12.         double totalTax = 0;
  13.  
  14.  
  15.         switch (city) {
  16.             case "Sofia":
  17.                 if (powerEngine <=37) {
  18.                     tax = powerEngine * 1.43;
  19.                     if ("Euro 4".equals(standart)) {
  20.                         discount = tax * 0.15;
  21.                         totalTax = tax - discount;
  22.                     }
  23.                     if ("Euro 5".equals(standart)) {
  24.                         discount = tax * 0.17;
  25.                         totalTax = tax - discount;
  26.                     }
  27.                     if ("Euro 6".equals(standart)) {
  28.                         discount = tax * 0.2;
  29.                         totalTax = tax - discount;
  30.                     }
  31.  
  32.                 }
  33.                  if (powerEngine >= 38 && powerEngine < 55) {
  34.                     tax = powerEngine * 1.5;
  35.                     if ("Euro 4".equals(standart)) {
  36.                         discount = tax * 0.15;
  37.                         totalTax = tax - discount;
  38.                     }
  39.                     if ("Euro 5".equals(standart)) {
  40.                         discount = tax * 0.17;
  41.                         totalTax = tax - discount;
  42.                     }
  43.                     if ("Euro 6".equals(standart)) {
  44.                         discount = tax * 0.2;
  45.                         totalTax = tax - discount;
  46.                     }
  47.  
  48.                 }
  49.                 if (powerEngine >= 55){
  50.                     tax = powerEngine * 2.68;
  51.                     if ("Euro 4".equals(standart)) {
  52.                         discount = tax * 0.15;
  53.                         totalTax = tax - discount;
  54.                     }
  55.                     if ("Euro 5".equals(standart)) {
  56.                         discount = tax * 0.17;
  57.                         totalTax = tax - discount;
  58.                     }
  59.                     if ("Euro 6".equals(standart)) {
  60.                         discount = tax * 0.2;
  61.                         totalTax = tax - discount;
  62.                     }
  63.  
  64.                 }
  65.  
  66.                 break;
  67.  
  68.             case "Vidin":
  69.                 if (powerEngine <=37) {
  70.                     tax = powerEngine * 1.34;
  71.                     if ("Euro 4".equals(standart)) {
  72.                         discount = tax * 0.15;
  73.                         totalTax = tax - discount;
  74.                     }
  75.                     if ("Euro 5".equals(standart)) {
  76.                         discount = tax * 0.17;
  77.                         totalTax = tax - discount;
  78.                     }
  79.                     if ("Euro 6".equals(standart)) {
  80.                         discount = tax * 0.2;
  81.                         totalTax = tax - discount;
  82.                     }
  83.  
  84.                 }
  85.                 if (powerEngine >= 38 && powerEngine < 55) {
  86.                     tax = powerEngine * 1.4;
  87.                     if ("Euro 4".equals(standart)) {
  88.                         discount = tax * 0.15;
  89.                         totalTax = tax - discount;
  90.                     }
  91.                     if ("Euro 5".equals(standart)) {
  92.                         discount = tax * 0.17;
  93.                         totalTax = tax - discount;
  94.                     }
  95.                     if ("Euro 6".equals(standart)) {
  96.                         discount = tax * 0.2;
  97.                         totalTax = tax - discount;
  98.                     }
  99.  
  100.                 }
  101.                 if (powerEngine >= 55){
  102.                     tax = powerEngine * 2.54;
  103.                     if ("Euro 4".equals(standart)) {
  104.                         discount = tax * 0.15;
  105.                         totalTax = tax - discount;
  106.                     }
  107.                     if ("Euro 5".equals(standart)) {
  108.                         discount = tax * 0.17;
  109.                         totalTax = tax - discount;
  110.                     }
  111.                     if ("Euro 6".equals(standart)) {
  112.                         discount = tax * 0.2;
  113.                         totalTax = tax - discount;
  114.                     }
  115.  
  116.                 }
  117.                 break;
  118.  
  119.  
  120.             case "Varna":
  121.                 if (powerEngine <=37) {
  122.                     tax = powerEngine * 1.37;
  123.                     if ("Euro 4".equals(standart)) {
  124.                         discount = tax * 0.15;
  125.                         totalTax = tax - discount;
  126.                     }
  127.                     if ("Euro 5".equals(standart)) {
  128.                         discount = tax * 0.17;
  129.                         totalTax = tax - discount;
  130.                     }
  131.                     if ("Euro 6".equals(standart)) {
  132.                         discount = tax * 0.2;
  133.                         totalTax = tax - discount;
  134.                     }
  135.  
  136.                 }
  137.                 if (powerEngine >= 38 && powerEngine < 55) {
  138.                     tax = powerEngine * 1.4;
  139.                     if ("Euro 4".equals(standart)) {
  140.                         discount = tax * 0.15;
  141.                         totalTax = tax - discount;
  142.                     }
  143.                     if ("Euro 5".equals(standart)) {
  144.                         discount = tax * 0.17;
  145.                         totalTax = tax - discount;
  146.                     }
  147.                     if ("Euro 6".equals(standart)) {
  148.                         discount = tax * 0.2;
  149.                         totalTax = tax - discount;
  150.                     }
  151.  
  152.                 }
  153.                 if (powerEngine >= 55){
  154.                     tax = powerEngine * 2.57;
  155.                     if ("Euro 4".equals(standart)) {
  156.                         discount = tax * 0.15;
  157.                         totalTax = tax - discount;
  158.                     }
  159.                     if ("Euro 5".equals(standart)) {
  160.                         discount = tax * 0.17;
  161.                         totalTax = tax - discount;
  162.                     }
  163.                     if ("Euro 6".equals(standart)) {
  164.                         discount = tax * 0.2;
  165.                         totalTax = tax - discount;
  166.                     }
  167.  
  168.                 }
  169.                 break;
  170.         }
  171.                 System.out.printf("%.2f",totalTax);
  172.     }
  173. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement