Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String city = scanner.nextLine();
- double quantity = Double.parseDouble(scanner.nextLine());
- double percent = 0;
- if ("Sofia".equals(city)){
- if (quantity >= 0 && quantity <= 500){
- percent = 5;
- } else if (quantity > 500 && quantity <= 1000){
- percent = 7;
- } else if(quantity > 1000 && quantity <= 10000){
- percent = 8;
- } else if (quantity > 10000){
- percent = 12;
- }
- } else if ("Varna".equals(city)){
- if (quantity >= 0 && quantity <= 500){
- percent = 4.5;
- } else if (quantity > 500 && quantity <= 1000){
- percent = 7.5;
- } else if(quantity > 1000 && quantity <= 10000){
- percent = 10;
- } else if (quantity > 10000){
- percent = 13;
- }
- } else if ("Plovdiv".equals(city)){
- if (quantity >= 0 && quantity <= 500){
- percent = 5.5;
- } else if (quantity > 500 && quantity <= 1000){
- percent = 8;
- } else if(quantity > 1000 && quantity <= 10000){
- percent = 12;
- } else {
- percent = 14.5;
- }
- }
- if (quantity >= 0 &&
- ("Sofia".equals(city) || "Varna".equals(city) || "Plovdiv".equals(city))) {
- double result = quantity * (percent / 100);
- System.out.printf("%.2f", result);
- } else {
- System.out.println("error");
- }
- }
- }
Add Comment
Please, Sign In to add comment