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