Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class honeymoon {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- String destination = scanner.nextLine();
- int countDays = Integer.parseInt(scanner.nextLine());
- double total = 0;
- double kairo = 2 * 250.0; //+ 600;
- double parij = 2 * 150.0; //+ 350;
- double lima = 2 * 400.0; //+ 850;
- double newYork = 2 * 300.0; //+ 650;
- double tokyo = 2 * 350.0; //+ 700;
- if (destination.equals("Cairo")) {
- if (countDays >= 1 && countDays <= 4) {
- total = (kairo*countDays+600)-((kairo*countDays+600)*3/100);
- } else if (countDays >= 5 && countDays <= 9) {
- total = (kairo*countDays+600)-((kairo*countDays+600 * 5 / 100.0));
- } else if (countDays >= 10 && countDays <= 24) {
- total = (kairo*countDays+600)-((kairo*countDays+600* 10 / 100.0));
- } else if (countDays >= 25 && countDays <= 49) {
- total =(kairo*countDays+600)-((kairo*countDays+600* 17 / 100.0));
- } else if(countDays>=50) {
- total = (kairo*countDays+600)-((kairo*countDays+600 * 30 / 100.0));
- }
- } else if (destination.equals("Paris")) {
- if (countDays >= 1 && countDays <= 4) {
- total = parij*countDays+350;
- } else if (countDays >= 5 && countDays <= 9) {
- total = (parij*countDays+350)- ((parij*countDays+350) * 7 / 100.0);
- } else if (countDays >= 10 && countDays <= 24) {
- total = (parij*countDays+350)- ((parij*countDays+350) * 12 / 100.0);
- } else if (countDays >= 25 && countDays <= 49) {
- total = (parij*countDays+350)- ((parij*countDays+350)*22 / 100.0);
- } else if(countDays>=50) {
- total = (parij*countDays+350)- ((parij*countDays+350)* 30 / 100.0);
- }
- } else if (destination.equals("Lima")) {
- if (countDays >= 1 && countDays <= 24) {
- total = lima*countDays+850;
- } else if (countDays >= 25 && countDays <= 49) {
- total = (lima*countDays+850)- ((lima*countDays+850) * 19 / 100.0);
- } else if(countDays>=50) {
- total = (lima*countDays+850)- ((lima*countDays+850)* 30 / 100.0);
- }
- } else if (destination.equals("New York")) {
- if (countDays >= 1 && countDays <= 4) {
- total = (newYork*countDays+650)- ((newYork*countDays+650) * 3 / 100.0);
- } else if (countDays >= 5 && countDays <= 9) {
- total = (newYork*countDays+650)- ((newYork*countDays+650) * (5 / 100.0));
- } else if (countDays >= 10 && countDays <= 24) {
- total = (newYork*countDays+650)- ((newYork*countDays+650)* 12 / 100.0);
- } else if (countDays >= 25 && countDays <= 49) {
- total = (newYork*countDays+650)- ((newYork*countDays+650) * (19 / 100.0));
- } else if(countDays>=50) {
- total = (newYork*countDays+650)- ((newYork*countDays+650) * 30 / 100.0);
- }
- } else if (destination.equals("Tokyo")) {
- if (countDays >= 1 && countDays <= 9) {
- total = tokyo*countDays+700;
- } else if (countDays >= 10 && countDays <= 24) {
- total = (tokyo*countDays+700)- ((tokyo*countDays+700) * 12 / 100.0);
- } else if (countDays >= 25 && countDays <= 49) {
- total = (tokyo*countDays+700)- ((tokyo*countDays+700) * 17 / 100.0);
- } else if(countDays>=50) {
- total = (tokyo*countDays+700)- ((tokyo*countDays+700)* (30 / 100.0));
- }
- }
- double diff = budget - total;
- if (budget > total) {
- System.out.printf("Yes! You have %.2f leva left.",diff);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", Math.abs(diff));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement