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 scan = new Scanner(System.in);
- String month = scan.nextLine();
- int nightsCount = Integer.parseInt(scan.nextLine());
- double studioPrice = 0;
- double doublePrice = 0;
- double suitePrice = 0;
- switch (month) {
- case "May":
- case "October":
- studioPrice = 50 * nightsCount;
- doublePrice = 65 * nightsCount;
- suitePrice = 75 * nightsCount;
- if (nightsCount > 7) {
- studioPrice = studioPrice * 0.95;
- }
- break;
- case "June":
- case "September":
- studioPrice = 60 * nightsCount;
- doublePrice = 72 * nightsCount;
- suitePrice = 82 * nightsCount;
- if (nightsCount > 14) {
- doublePrice = doublePrice * 0.9;
- }
- break;
- case "July":
- case "August":
- case "December":
- studioPrice = 68 * nightsCount;
- doublePrice = 77 * nightsCount;
- suitePrice = 89 * nightsCount;
- if (nightsCount > 14) {
- suitePrice = suitePrice * 0.85;
- }
- break;
- }
- if (month.equals("September") && nightsCount > 7) {
- studioPrice -= 60;
- }
- if (month.equals("October") && nightsCount > 7) {
- studioPrice -= 50 * 0.95;
- }
- System.out.println(String.format("Studio: %.2f lv.", studioPrice));
- System.out.println(String.format("Double: %.2f lv.", doublePrice));
- System.out.println(String.format("Suite: %.2f lv.", suitePrice));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement