Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TradeCommissions {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String city = scan.nextLine();
- double sells = Double.parseDouble(scan.nextLine());
- boolean other = city.equals("Sofia") || city.equals("Varna") || city.equals("Plovdiv");
- boolean other2 = sells < 0;
- double commission = sells * 1;
- switch (city) {
- case "Sofia":
- if (sells >= 0 && sells <= 500) {
- commission = sells * 0.05;
- } else if (sells > 500 && sells <= 1000) {
- commission = sells * 0.07;
- } else if (sells > 1000 && sells <= 10000) {
- commission = sells * 0.08;
- } else if (sells > 10000) {
- commission = sells * 0.12;
- }
- break;
- case "Varna":
- if (sells >= 0 && sells <= 500) {
- commission = sells * 0.045;
- } else if (sells > 500 && sells <= 1000) {
- commission = sells * 0.075;
- } else if (sells > 1000 && sells <= 10000) {
- commission = sells * 0.1;
- } else if (sells > 10000) {
- commission = sells * 0.13;
- }
- break;
- case "Plovdiv":
- if (sells >= 0 && sells <= 500) {
- commission = sells * 0.055;
- } else if (sells > 500 && sells <= 1000) {
- commission = sells * 0.08;
- } else if (sells > 1000 && sells <= 10000) {
- commission = sells * 0.12;
- } else if (sells > 10000) {
- commission = sells * 0.145;
- }
- break;
- }
- if (other && !other2) {
- System.out.printf("%.2f", commission);
- } else {
- System.out.println("error");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement