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