Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class HotelRoom {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- String month = in.nextLine();
- int night = in.nextInt();
- double price = 0;
- double apartment = 0;
- double studio = 0;
- switch(month) {
- case "May":
- case "October":
- if(night <= 7) {
- apartment = night * 65;
- studio = night * 50;
- }else if(night > 7 && night <= 14) {
- double discount = 50 * 0.05;
- studio = night * (50 - discount);
- apartment = night * 65;
- }else if(night > 14) {
- double discount = 50 * 0.3;
- studio = night * (50 - discount);
- double discountA = 65 * 0.1;
- apartment = night * (65 - discountA);
- }
- break;
- case "June":
- case "September":
- if(night <= 7) {
- apartment = night * 68.70;
- studio = night * 75.20;
- }else if(night > 7 && night <= 14) {
- studio = night * 75.20;
- apartment = night * 68.70;
- }else if(night > 14) {
- double discount = 75.20 * 0.2;
- studio = night * (75.20 - discount);
- double discountA = 68.70 * 0.1;
- apartment = night * (68.70 - discountA);
- }
- break;
- case "July":
- case "August":
- if(night <=14) {
- studio = night * 76;
- apartment = night * 77;
- }else if(night > 14) {
- studio = night * 76;
- double discountA = 77 * 0.1;
- apartment = night * (77 - discountA);
- }
- break;
- default:
- System.out.println("error");
- }
- System.out.printf("Apartment: %.2f lv.", apartment);
- System.out.printf("\nStudio: %.2f lv.", studio);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement