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 scanner = new Scanner(System.in);
- String month = scanner.nextLine();
- int overnights = Integer.parseInt(scanner.nextLine());
- double studioPrice = 0;
- double apartmentPrice = 0;
- switch (month) {
- case "May":
- case "October":
- studioPrice = 50;
- apartmentPrice = 65;
- if (overnights > 14) {
- studioPrice *= 0.7;
- } else if (overnights > 7) {
- studioPrice *= 0.95;
- }
- break;
- case "June":
- case "September":
- studioPrice = 75.2;
- apartmentPrice = 68.7;
- if (overnights > 14){
- studioPrice *= 0.8;
- }
- break;
- case "July":
- case "August":
- studioPrice = 76;
- apartmentPrice = 77;
- break;
- }
- if (overnights > 14){
- apartmentPrice *= 0.9;
- }
- System.out.printf("Apartment: %.2f lv.%n", apartmentPrice * overnights);
- System.out.printf("Studio: %.2f lv.", studioPrice * overnights);
- }
- }
Add Comment
Please, Sign In to add comment