Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Hotel {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String month = scanner.nextLine().toLowerCase();
- short nights = Short.parseShort(scanner.nextLine());
- float studioPrice = 0.0f;
- float doublePrice = 0.0f;
- float suitePrice = 0.0f;
- switch (month) {
- case "may":
- case "october":
- studioPrice = 50f;
- doublePrice = 65f;
- suitePrice = 75f;
- if (nights > 7) {
- studioPrice *= 0.95f;
- }
- break;
- case "june":
- case "september":
- studioPrice = 60f;
- doublePrice = 72f;
- suitePrice = 82f;
- if (nights > 14) {
- doublePrice *= 0.9f;
- }
- break;
- case "july":
- case "august":
- case "december":
- studioPrice = 68f;
- doublePrice = 77f;
- suitePrice = 89f;
- if (nights > 14) {
- suitePrice *= 0.85f;
- }
- break;
- default:
- break;
- }
- float moneyForStudio = studioPrice * nights;
- float moneyForDouble = doublePrice * nights;
- float moneyForSuite = suitePrice * nights;
- if (nights > 7 && (month.equals("september") || month.equals("october"))) {
- moneyForStudio = studioPrice * (nights - 1);
- }
- System.out.printf("Studio: %.2f lv.\n", moneyForStudio);
- System.out.printf("Double: %.2f lv.\n", moneyForDouble);
- System.out.printf("Suite: %.2f lv.", moneyForSuite);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement