Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rt java.util.Scanner;
- public class Hotel {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- System.out.print("Enter month: ");
- String month = keyboard.next();
- System.out.print("Enter length of stay: ");
- int stay = keyboard.nextInt();
- switch (month) {
- case "May":
- case "October":
- if (stay <= 7) {
- double priceSt = stay * 50.0;
- double priceAp = stay * 65.0;
- System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
- } else if (7 < stay && stay <= 14) {
- double priceSt = (stay * 50.0) * 0.95;
- double priceAp = stay * 65.0;
- System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
- } else {
- double priceSt = (stay * 50.0) * 0.7;
- double priceAp = stay * 65.0 * 0.9;
- System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
- }
- break;
- case "July":
- case "September":
- if (stay <= 7) {
- double priceSt = stay * 72.5;
- double priceAp = stay * 68.7;
- System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
- } else if (7 <= stay && stay <=14) {
- double priceSt = (stay * 72.5) * 0.95;
- double priceAp = stay * 68.7;
- System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
- } else {
- double priceSt = (stay * 50.0) * 0.8;
- double priceAp = stay * 65.0 * 0.9;
- System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
- }
- break;
- case "June":
- case "August":
- if (stay <= 7) {
- double priceSt = stay * 76;
- double priceAp = stay * 77;
- System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
- }else if (7 < stay && stay <= 14){
- double priceSt = (stay * 76) * 0.95;
- double priceAp = (stay * 77);
- System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
- } else {
- double priceSt = (stay * 76) * 0.8;
- double priceAp = (stay * 77) * 0.9;
- System.out.printf("%.2f lv. Studio %n%.2f lv. Apartment", priceSt, priceAp);
- }
- break;
- default: {
- System.out.println("We are closed");
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement