Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package L03_ConditionalStatementsAdvanced;
- import java.util.Scanner;
- public class P05_Journey {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- String season = scanner.nextLine();
- //създаваме променливи, в които да запазим: къде ще почива, какъв тип ще бъде настаняването, колко е изхарчил
- String destination = "";
- String accommodationType = "";
- double spendMoney = 0;
- //правим проверка за бюджета -> <=100 България, <= 1000 Балканите, всички останали случаи -> Европа
- //проверяваме къде ще почива и кой е сезона
- if(budget <= 100 && season.equals("summer")){
- destination = "Bulgaria";
- accommodationType = "Camp";
- spendMoney = budget * 0.3;
- /* if(season.equals("summer")){
- accommodationType = "Camp";
- spendMoney = budget * 0.3;
- }else {
- accommodationType = "Hotel";
- spendMoney = budget * 0.7;
- }*/
- }else if(budget <= 100 && season.equals("winter")){
- destination = "Bulgaria";
- accommodationType = "Hotel";
- spendMoney = budget * 0.7;
- } else if (budget <= 1000 && season.equals("summer")) {
- destination = "Balkans";
- accommodationType = "Camp";
- spendMoney = budget * 0.4;
- } else if (budget <= 1000 && season.equals("winter")) {
- destination = "Balkans";
- accommodationType = "Hotel";
- spendMoney = budget * 0.8;
- }else {
- destination = "Europe";
- accommodationType = "Hotel";
- spendMoney = budget * 0.9;
- }
- System.out.printf("Somewhere in %s%n", destination);
- System.out.printf("%s - %.2f", accommodationType, spendMoney);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment