Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ComplexConditionalStatements.Exercises;
- import java.util.Scanner;
- public class j_HotelRoom {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- String month = console.nextLine();
- int nights = Integer.parseInt(console.nextLine());
- double studio = 0;
- double apartment = 0;
- switch (month){
- case "May":
- case "October":
- studio = 50;
- apartment = 65;
- if (nights > 14){
- studio *= 0.70;
- } else if (nights > 7){
- studio *= 0.95;
- }
- break;
- case "June":
- case "September":
- studio = 75.20;
- apartment = 68.70;
- if (nights > 14){
- studio *= 0.80;
- }
- break;
- case "July":
- case "August":
- studio = 76;
- apartment = 77;
- break;
- }
- if(nights > 14){
- apartment *= 0.90;
- }
- System.out.printf("Apartment: %.2f lv.%n",apartment * nights);
- System.out.printf("Studio: %.2f lv.",studio * nights);
- }
- }
Add Comment
Please, Sign In to add comment