Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TaxCalculator {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int powerEngine = Integer.parseInt(scanner.nextLine());
- String city = scanner.nextLine();
- String standart =scanner.nextLine();
- double tax = 0;
- double discount = 0;
- double totalTax = 0;
- switch (city) {
- case "Sofia":
- if (powerEngine <=37) {
- tax = powerEngine * 1.43;
- if ("Euro 4".equals(standart)) {
- discount = tax * 0.15;
- totalTax = tax - discount;
- }
- if ("Euro 5".equals(standart)) {
- discount = tax * 0.17;
- totalTax = tax - discount;
- }
- if ("Euro 6".equals(standart)) {
- discount = tax * 0.2;
- totalTax = tax - discount;
- }
- }
- if (powerEngine >= 38 && powerEngine < 55) {
- tax = powerEngine * 1.5;
- if ("Euro 4".equals(standart)) {
- discount = tax * 0.15;
- totalTax = tax - discount;
- }
- if ("Euro 5".equals(standart)) {
- discount = tax * 0.17;
- totalTax = tax - discount;
- }
- if ("Euro 6".equals(standart)) {
- discount = tax * 0.2;
- totalTax = tax - discount;
- }
- }
- if (powerEngine >= 55){
- tax = powerEngine * 2.68;
- if ("Euro 4".equals(standart)) {
- discount = tax * 0.15;
- totalTax = tax - discount;
- }
- if ("Euro 5".equals(standart)) {
- discount = tax * 0.17;
- totalTax = tax - discount;
- }
- if ("Euro 6".equals(standart)) {
- discount = tax * 0.2;
- totalTax = tax - discount;
- }
- }
- break;
- case "Vidin":
- if (powerEngine <=37) {
- tax = powerEngine * 1.34;
- if ("Euro 4".equals(standart)) {
- discount = tax * 0.15;
- totalTax = tax - discount;
- }
- if ("Euro 5".equals(standart)) {
- discount = tax * 0.17;
- totalTax = tax - discount;
- }
- if ("Euro 6".equals(standart)) {
- discount = tax * 0.2;
- totalTax = tax - discount;
- }
- }
- if (powerEngine >= 38 && powerEngine < 55) {
- tax = powerEngine * 1.4;
- if ("Euro 4".equals(standart)) {
- discount = tax * 0.15;
- totalTax = tax - discount;
- }
- if ("Euro 5".equals(standart)) {
- discount = tax * 0.17;
- totalTax = tax - discount;
- }
- if ("Euro 6".equals(standart)) {
- discount = tax * 0.2;
- totalTax = tax - discount;
- }
- }
- if (powerEngine >= 55){
- tax = powerEngine * 2.54;
- if ("Euro 4".equals(standart)) {
- discount = tax * 0.15;
- totalTax = tax - discount;
- }
- if ("Euro 5".equals(standart)) {
- discount = tax * 0.17;
- totalTax = tax - discount;
- }
- if ("Euro 6".equals(standart)) {
- discount = tax * 0.2;
- totalTax = tax - discount;
- }
- }
- break;
- case "Varna":
- if (powerEngine <=37) {
- tax = powerEngine * 1.37;
- if ("Euro 4".equals(standart)) {
- discount = tax * 0.15;
- totalTax = tax - discount;
- }
- if ("Euro 5".equals(standart)) {
- discount = tax * 0.17;
- totalTax = tax - discount;
- }
- if ("Euro 6".equals(standart)) {
- discount = tax * 0.2;
- totalTax = tax - discount;
- }
- }
- if (powerEngine >= 38 && powerEngine < 55) {
- tax = powerEngine * 1.4;
- if ("Euro 4".equals(standart)) {
- discount = tax * 0.15;
- totalTax = tax - discount;
- }
- if ("Euro 5".equals(standart)) {
- discount = tax * 0.17;
- totalTax = tax - discount;
- }
- if ("Euro 6".equals(standart)) {
- discount = tax * 0.2;
- totalTax = tax - discount;
- }
- }
- if (powerEngine >= 55){
- tax = powerEngine * 2.57;
- if ("Euro 4".equals(standart)) {
- discount = tax * 0.15;
- totalTax = tax - discount;
- }
- if ("Euro 5".equals(standart)) {
- discount = tax * 0.17;
- totalTax = tax - discount;
- }
- if ("Euro 6".equals(standart)) {
- discount = tax * 0.2;
- totalTax = tax - discount;
- }
- }
- break;
- }
- System.out.printf("%.2f",totalTax);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement