import java.util.Scanner; public class S210316033 { public static void main(String[] args) { /* Furkan Baytak 210316033 */ Scanner input = new Scanner(System.in); double room1 = 200; //2-Person room price double room2 = 170; //3-Person room price double room3 = 150; //4-Person room price double basePrice = 0; //It'll start from 0 and rise with calculations int child = 0; //It's necesarry for calculations in very bottom System.out.println(" How many guests will stay at the hotel?"); int guestNumber = input.nextInt(); int noChild = guestNumber - 1; //"guestNumber - child" = guestNumber without kids if(guestNumber == 1){ basePrice = room1 + 80;} //One person in 2-Person room calculation else if(guestNumber > 1){ System.out.println("Are you family or group of friends?"); String familyOrFriends = input.next(); /*If guestNumber can be divided by 4 with no remainder all the guests will stay at 4-Person rooms. Else the remainder count will be the number of how many person will stay at the remaining room (non 4-Person room) or how many person stay at one room.(Calculations will be detailed by the number of child)*/ if("friends".equalsIgnoreCase(familyOrFriends) || "friend".equalsIgnoreCase(familyOrFriends)){ if(guestNumber > 1 && guestNumber < 4) { if(guestNumber == 2){ basePrice = guestNumber * room1;} else if(guestNumber == 3){ basePrice = guestNumber * room2;} } else if(guestNumber >= 4) { if(guestNumber % 4 == 0){ basePrice = guestNumber * room3;} else if(guestNumber % 4 == 1){ basePrice = (guestNumber - 1) * room3 + room1 + 80;} //It's +80TL because there is one person in 2-Person room. else if(guestNumber % 4 == 2){ basePrice = (guestNumber - 2) * room3 + 2 * room1;} else if(guestNumber % 4 == 3){ basePrice = (guestNumber - 3) * room3 + 3 * room2;} } } else if("family".equalsIgnoreCase(familyOrFriends)){ System.out.println("Is there any children?"); System.out.println(" Yes(Y) No(N) "); String children = input.next(); switch(children.toUpperCase()){ //Kids always stays at high numbered room. case "Y": System.out.println("How many ?"); child = input.nextInt(); if(child == 1){ if(guestNumber <= 4 && guestNumber > 1) { if(guestNumber == 2){ basePrice = (guestNumber - 1) * (room1 + 80) + room1 / 2;} //Even if there is a kid an adult stays at 2-Person room. else if(guestNumber == 3){ basePrice = (guestNumber - 1) * room1 + room1 / 2;} else if(guestNumber == 4){ basePrice = (guestNumber - 1) * room2 + room2 / 2;} break; } else if(guestNumber >= 5) { if(noChild % 4 == 0){ //We're calculating it with "guestNumber - 1" basePrice = (guestNumber - 1) * room3 + room3 / 2;} else if(noChild % 4 == 1){ basePrice = (guestNumber - 2) * room3 + (room1 + 80) + room3 / 2;} //It's +80TL because there is one person in 2-Person room. else if(noChild % 4 == 2){ basePrice = (guestNumber - 3) * room3 + 2 * room1 + room3 / 2;} else if(noChild % 4 == 3){ basePrice = (guestNumber - 4) * room3 + 3 * room2 + room3 / 2;} break; } } else if(child > 1){ /*If there is more than one child the calcuation made like "friends" or with "child = 0" and then we've made discount from high numbered room for kids because kids always stays with their parents.*/ if(guestNumber <= 3 && guestNumber > 5) { //Min guestNumber is 3 because there is min 2 kids and 1 parent. if(guestNumber == 3){ basePrice = guestNumber * room2 - child * (room2 * 25 / 100);} else if(guestNumber == 4){ basePrice = guestNumber * room3 - child * (room3 * 25 / 100);} break; } else if(guestNumber >= 5) //Kids always stays at 4-Person room with their parents. { if(guestNumber % 4 == 0){ basePrice = guestNumber * room3 - child * (room3 * 25 / 100);} else if(guestNumber % 4 == 1){ basePrice = (guestNumber - 1) * room3 + (room1 + 80) - child * (room3 * 25 / 100);} //It's +80TL because there is one person in 2-Person room. else if(guestNumber % 4 == 2){ basePrice = (guestNumber - 2) * room3 + room1 - child * (room3 * 25 / 100);} else if(guestNumber % 4 == 3){ basePrice = (guestNumber -3) * room3 + room2 - child * (room3 * 25 / 100);} break; } } case "N": if(guestNumber > 1 && guestNumber < 4) { if(guestNumber == 2){ basePrice = guestNumber * room1;} else if(guestNumber == 3){ basePrice = guestNumber * room2;} } else if(guestNumber >= 4) { if(guestNumber % 4 == 0){ basePrice = guestNumber * room3;} else if(guestNumber % 4 == 1){ basePrice = (guestNumber - 1) * room3 + room1 + 80;} //It's +80TL because there is one person in 2-Person room. else if(guestNumber % 4 == 2){ basePrice = (guestNumber - 2) * room3 + 2 * room1;} else if(guestNumber % 4 == 3){ basePrice = (guestNumber - 3) * room3 + 3 * room2;} } break; } } else{ System.out.println("Please just write \"Friends\" or \"Family\""); System.exit(0); } } /*basePrice calculated.There is just "are you VIP" and "how many days" questions left.*/ System.out.println("Are you a VIP member ?"); System.out.println(" Yes(Y) No(N)"); String vip = input.next(); switch(vip.toUpperCase()) { case "Y": basePrice -= basePrice * 5 / 100; break; case "N": break; default: System.out.println("Please just say \"Y\" or \"N\""); System.exit(0); } /*After VIP discount basePrice has been changed and there is how many days questions left.*/ System.out.println("How many days will you stay?"); int days = input.nextInt(); if(days == 1 || days == 2){ System.out.println("Will you stay on weekend or weekdays?"); System.out.println("For weekend press \"1\" and for weekdays press \"2\""); int weekdys = input.nextInt(); switch(weekdys){ case 1: break; case 2: basePrice -= basePrice * 3 / 100; break; default: System.out.println("Please just say \"1\" or \"2\""); System.exit(0); } } else if(days >= 3 && days <= 7) basePrice -= basePrice * 4 / 100; else if(days > 7) basePrice -= basePrice * 6 / 100; basePrice *= days; // We've calculated the new basePrice with multiply it with day count. /*final basePrice has been calculated now we'll print how many rooms has been booked, how many person, for how long they've booked and for at what basePrice after we asked if they want to book.*/ System.out.println("Final price after all calculations is: " +basePrice + " TL"); System.out.println("Do you want to book the room ?"); System.out.println("Please press \"Y\" for Yes and \"N\" for No."); String doYou = input.next(); input.close(); // I've closed the scanner which i've opened at the beggining. switch(doYou.toUpperCase()){ case "Y": int restP = guestNumber % 4; // number of how many person will stay at non 4-Person room. int fourP = guestNumber / 4; // 4-Person room number if(child == 1){ //If there is just one child there is spesific printing processes. guestNumber -= child; if(guestNumber < 4) System.out.println("Congrats ! You've booked one " + restP + "-Person room for " + (guestNumber + child) + " guests and for " +days + " days."); else if(guestNumber == 4) System.out.println("Congrats ! You've booked one 4-Person room for " + (guestNumber + child) + " guests and for " +days + " days."); else if(guestNumber % 4 == 0) System.out.println("Congrats ! You've booked " + fourP + " 4-Person rooms for " + (guestNumber + child) + " guests and for " +days + " days."); else if(guestNumber > 4) System.out.println("Congrats ! You've booked " + fourP + " 4-Person rooms and one " +restP + "-Person room for " + (guestNumber + child) + " guests and for " +days + " days."); System.out.println("Total Cost is: " + basePrice + "TL"); System.out.println("Thanks for choosing us have a great day !");} else if(child > 1 || child == 0){ //If there is more than just one child and if everything is normal there is printing processes. if(guestNumber < 4) System.out.println("Congrats ! You've booked one " + restP + "-Person room for " +guestNumber + " guests and for " +days + " days."); else if(guestNumber == 4) System.out.println("Congrats ! You've booked one 4-Person room for " +guestNumber + " guests and for " +days + " days."); else if(guestNumber % 4 == 0) System.out.println("Congrats ! You've booked " + fourP + " 4-Person rooms for " +guestNumber + " guests and for " +days + " days."); else if(guestNumber > 4) System.out.println("Congrats ! You've booked " + fourP + " 4-Person rooms and one " +restP + "-Person room for " +guestNumber + " guests and for " +days + " days."); System.out.println("Total Cost is: " + basePrice + "TL"); System.out.println("Thanks for choosing us have a great day !");} break; case "N": System.out.println("Ok then have a good day !"); break; default: System.out.println("Please just say \"Y\" or \"N\""); System.exit(0); } } }