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