Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class NewHome {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- Integer budget = Integer.parseInt(scanner.nextLine());
- String season = scanner.nextLine();
- Integer numberPeople = Integer.parseInt(scanner.nextLine());
- Double totalPrice = 0.00;
- switch (season){
- case "Spring":
- if (numberPeople <= 6){
- totalPrice = 3000-(3000*0.10);
- }else if(numberPeople >= 7 && numberPeople <=11){
- totalPrice = 3000-(3000*0.15);
- }else if(numberPeople >11){
- totalPrice = 3000-(3000*0.25);
- }else{}
- if(numberPeople % 2 == 0){
- totalPrice = totalPrice - totalPrice*0.05;
- }else{}
- break;
- case "Summer":
- if (numberPeople <= 6){
- totalPrice = 4200-(4200*0.10);
- }else if(numberPeople >= 7 && numberPeople <=11){
- totalPrice = 4200-(4200*0.15);
- }else if(numberPeople >11){
- totalPrice = 4200-(4200*0.25);
- }else{}
- if(numberPeople % 2 == 0){
- totalPrice = totalPrice - totalPrice*0.05;
- }else{}
- break;
- case "Autumn":
- if (numberPeople <= 6){
- totalPrice = 4200-(4200*0.10);
- }else if(numberPeople >= 7 && numberPeople <=11){
- totalPrice = 4200-(4200*0.15);
- }else if(numberPeople >11){
- totalPrice = 4200-(4200*0.25);
- }else{}
- break;
- case "Winter":
- if (numberPeople <= 6){
- totalPrice = 2600-(2600*0.10);
- }else if(numberPeople >= 7 && numberPeople <=11){
- totalPrice = 2600-(2600*0.15);
- }else if(numberPeople >11){
- totalPrice = 2600-(2600*0.25);
- }else{}
- if(numberPeople % 2 == 0){
- totalPrice = totalPrice - totalPrice*0.05;
- }else{}
- break;
- default:
- break;
- }
- double finalAmount = Math.abs(totalPrice - budget);
- if (totalPrice <= budget) {
- System.out.printf("Yes! You have %.2f leva left.", finalAmount);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", finalAmount);
- }
- }
- }
Add Comment
Please, Sign In to add comment