Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: help me please..

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default help me please..

    anybody know what's wrong with my code start from this part:

    if (roomNumber == 1){
    if (HouseA1[roomNumber-1] < 2) {
    HouseA1 [roomNumber-1] += 1;


    why i can't book a room again in the that house?
    because the house has 2 room right, when i book the first room it's successful, but then when i book again for room 2 its say it's already booked..
    u know why this happens..?
    thanks b4..


    import java.text.*;
    import java.util.*;
     
    public class University_Apartment
    {
        public static void main (String[]arguments)
        {
            String studentName, studentID, passportNumber, currentDate, assignDate, currentHour, apartmentType1, apartmentType2;
            String userInputMain, userInputI, userInputR, userInputR1, userInputView;
            String userChoiceFullA, userChoiceFullB;
     
            char optionMain, optionInputI,optionInputR, optionInputView;
            char optionChoiceFullA, optionChoiceFullB;
     
            int indexHouseA,indexHouseB;
            int houseNumber, roomNumber;
     
    	final int roomA = 2;
    	final int roomB = 3;
            boolean next = false;
            boolean nextA = false;
            boolean nextB = false;
     
    	int[] HouseA1 = new int[roomA];
    	int[] HouseA2 = new int[roomA];
            int[] HouseA3 = new int[roomA];
            int[] HouseA4 = new int[roomA];
            int[] HouseA5 = new int[roomA];
    	int[] HouseB1 = new int[roomB];
    	int[] HouseB2 = new int[roomB];
            int[] HouseB3 = new int[roomB];
            int[] HouseB4 = new int[roomB];
            int[] HouseB5 = new int[roomB];
     
            Scanner keyboard = new Scanner (System.in);
     
            do {
            System.out.println();
            System.out.println("************************************");
    	System.out.println("****** Fortes Fortuna Apartment ****");
            System.out.println("*==================================*");
    	System.out.println("*            MAIN MENU             *");
    	System.out.println("*==================================*");
            System.out.println("*      I => Apartment Info         *");
    	System.out.println("*      R => Register New Student   *");
    	System.out.println("*      V => View Occupancy         *");
            System.out.println("*      S => Search Student         *");
    	System.out.println("*      Q => Quit                   *");
            System.out.println("*                                  *");
            System.out.println("*==================================*");
            System.out.println();
            System.out.print  ("Enter : ");
            userInputMain = keyboard.nextLine();
    	optionMain = userInputMain.charAt(0);
     
    	switch(optionMain)
    	{
                  case 'i' : case 'I':
                       System.out.println();
                       System.out.println("#=======================================#");
                       System.out.println("#         APARTMENT INFORMATION         #");
                       System.out.println("#=======================================#");
                       System.out.println("#                                       #");
                       System.out.println("#        A => Info Apartment A          #");
                       System.out.println("#        B => Info Apartment B          #");
                       System.out.println("#        M => return to Main Menu       #");
                       System.out.println("#                                       #");
                       System.out.println("#=======================================#");
                       System.out.print  ("Enter : ");
                       userInputI = keyboard.nextLine();
                       optionInputI = userInputI.charAt(0);
     
                            if(optionInputI == 'm' || optionInputI == 'M') {
                                System.out.println();
                                System.out.println("Back to Main Menu.");
                                System.out.println();
                                }
                            else if(optionInputI == 'a' || optionInputI == 'A') {
                                System.out.println();
                                System.out.println(":::::::::::::::::::::::::::::::::::::::::::::::::::");
                                System.out.println("::::            Apartment Type A               ::::");
                                System.out.println("::===============================================::");
                                System.out.println("::              * 2 bedrooms                     ::");
                                System.out.println(":: * Equipped with kitchen & laundry facilities  ::");
                                System.out.println("::         * Monthly rental = RM300.             ::");
                                System.out.println("::                                               ::");
                                System.out.println(":::::::::::::::::::::::::::::::::::::::::::::::::::");
                                }
                            else if (optionInputI == 'b' || optionInputI == 'B') {
                                System.out.println();
                                System.out.println(":::::::::::::::::::::::::::::::::::::::::::::::::::");
                                System.out.println("::::               Apartment Type B            ::::");
                                System.out.println(":::::::::::::::::::::::::::::::::::::::::::::::::::");
                                System.out.println("::      2 normal bedrooms & 1 master bedroom     ::");
                                System.out.println("::            Without kitchen and laundry        ::");
                                System.out.println("::              Monthly rental = RM200           ::");
                                System.out.println("___________________________________________________");
                                System.out.println("  * Master bedroom attached with inside bathroom   ");
                                System.out.println(" ** People who live in master bedroom              ");
                                System.out.println("                  will be paying 40% more = RM280  ");
                                System.out.println("___________________________________________________");
                                System.out.println();
                                }
     
                            break;
     
     
     
     
                  case 'r': case 'R':
     
                        DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
                        Date current = new Date();
                        DateFormat time = DateFormat.getTimeInstance(DateFormat.DEFAULT, Locale.ENGLISH);
                        currentHour = time.format( current );
                        Calendar today = Calendar.getInstance();
                        currentDate = sdf.format(today.getTime());
                        today.add(Calendar.DATE,140);
                        assignDate = sdf.format(today.getTime());
     
     
                        System.out.println();
                        System.out.println("    Register New Student");
                        System.out.println("---------------------------------");
                        System.out.println("Enter your name : ");
                        studentName = keyboard.nextLine();
                        System.out.println();
     
                        System.out.println("Enter your Full Student ID (ex: TP123456): ");
                        studentID = keyboard.nextLine();
                        System.out.println();
     
     
                        System.out.println("Enter your Full Passport Number(include the Letter): ");
                        passportNumber = keyboard.nextLine();
                        System.out.println();
     
     
                        System.out.println("Which apartment type you want? (A/B)");
                        userInputI = keyboard.nextLine();
                        optionInputI = userInputI.charAt(0);
                        System.out.println();
     
                        if(optionInputI == 'a' || optionInputI == 'A') {
                            apartmentType1 = "Apartment Type A";
     
                                    System.out.println("Which house do you want?");
                                    System.out.println("#.  House");
                                    System.out.println("1     A1 ");
                                    System.out.println("2     A2 ");
                                    System.out.println("3     A3 ");
                                    System.out.println("4     A4 ");
                                    System.out.println("5     A5 ");
                                    System.out.print("Enter: ");
                                    userInputR = keyboard.nextLine();
    				houseNumber = Integer.parseInt(userInputR);
     
                                    switch(houseNumber) {
     
                                    case 1 :
     
                                        house :
                                        for (indexHouseA = 0; indexHouseA <=HouseA1.length; indexHouseA++) {
    					if (indexHouseA == 2) {
    						System.out.println();
                                                    System.out.println("Sorry, this house is full.");
                                                    System.out.println("Please look for another house");
                                                    System.out.println(" M - Back to Main Menu");
                                                    System.out.println(" Q - Quit ");
                                                    userChoiceFullA = keyboard.nextLine();
                                                    optionChoiceFullA = userChoiceFullA.charAt(0);
     
                                                    if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                    System.out.println();
                                                    System.out.println("Main Menu.");
                                                    }
                                                    else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                    System.exit(0);
                                                    }break;
                                                    }
     
                                            else if (HouseA1[indexHouseA] < 1){
                                                System.out.println();
                                                System.out.println("Which room do you want? (1/2)");
                                                userInputR1 = keyboard.nextLine();
                                                roomNumber = Integer.parseInt(userInputR1);
     
                                                if (roomNumber == 1){
                                                    if (HouseA1[roomNumber-1] < 2) {
                                                    HouseA1 [roomNumber-1] += 1;
                                                    nextA = true;
     
                                                    System.out.println("Thanks, your room is in room number "+roomNumber+", house "+houseNumber+" "+
                                                                       "on "+apartmentType1+".");
                                                    System.out.println("Please pay all the administration fees.");
                                                    System.out.println("You will be assigned till "+ assignDate +".");
                                                    }
     
                                                    else {
                                                        nextA = false;
                                                        System.out.println();
                                                        System.out.println("Sorry, this room is already booked");
                                                        System.out.println("Please look for another room");
                                                    } break;
                                                }
     
                                                else if (roomNumber == 2){
                                                    if (HouseA1[roomNumber-2] < 2 ) {
                                                    HouseA1 [roomNumber-2] += 1;
                                                    nextA = true;
     
                                                    System.out.println("Thanks, your room is in room number "+roomNumber+", house "+houseNumber+" "+
                                                                       "on "+apartmentType1+".");
                                                    System.out.println("Please pay all the administration fees.");
                                                    System.out.println("You will be assigned till "+ assignDate +".");
                                                    }
     
                                                    else {
                                                        nextA = false;
                                                        System.out.println();
                                                        System.out.println("Sorry, this room is already booked");
                                                        System.out.println("Please look for another room");
                                                    } break;
                                                }
     
                                                else {
                                                    nextA = false;
                                                    System.out.println();
                                                    System.out.println("Wrong type, back to Main Menu.");
                                                }break;
                                            }
     
     
                                            else {
                                                nextA = false;
                                                System.out.println();
                                                System.out.println();
                                                System.out.println("Sorry, this house is already booked");
                                                System.out.println("Please look for another room");
                                                System.out.println(" M - Back to Main Menu");
                                                System.out.println(" Q - Quit ");
                                                userChoiceFullA = keyboard.nextLine();
                                                optionChoiceFullA = userChoiceFullA.charAt(0);
                                                if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                System.out.println();
                                                System.out.println("Main Menu.");
                                                }
                                                else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                System.exit(0);
                                                }
                                                    }break;
                                                }break;
     
     
                                    case 2 :
     
                                        for (indexHouseA = 0; indexHouseA <=HouseA2.length; indexHouseA++) {
    					if (indexHouseA == 2) {
    						System.out.println();
                                                    System.out.println("Sorry, this house is full.");
                                                    System.out.println("Please look for another house");
                                                    System.out.println(" M - Back to Main Menu");
                                                    System.out.println(" Q - Quit ");
                                                    userChoiceFullA = keyboard.nextLine();
                                                    optionChoiceFullA = userChoiceFullA.charAt(0);
     
                                                    if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                    System.out.println();
                                                    System.out.println("Main Menu.");
                                                    }
                                                    else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                    System.exit(0);
                                                    }break;
                                                    }
     
                                            else if (HouseA2[indexHouseA] < 1){
                                                System.out.println();
                                                System.out.println("Which room do you want? (1/2)");
                                                userInputR1 = keyboard.nextLine();
                                                roomNumber = Integer.parseInt(userInputR1);
     
                                                if (roomNumber == 1){
                                                    if (HouseA2[roomNumber-1] == 0 ) {
                                                    HouseA2 [roomNumber-1] += 1;
                                                    nextA = true;
     
                                                    System.out.println("Thanks, your room is in room number "+roomNumber+", house "+houseNumber+" "+
                                                                       "on "+apartmentType1+".");
                                                    System.out.println("Please pay all the administration fees.");
                                                    System.out.println("You will be assigned till "+ assignDate +".");
                                                    }
                                                }
     
                                                else {
                                                nextA = false;
                                                System.out.println();
                                                System.out.println();
                                                System.out.println("Sorry, this room is already booked");
                                                System.out.println("Please look for another room");
                                                System.out.println(" M - Back to Main Menu");
                                                System.out.println(" Q - Quit ");
                                                userChoiceFullA = keyboard.nextLine();
                                                optionChoiceFullA = userChoiceFullA.charAt(0);
                                                if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                System.out.println();
                                                System.out.println("Main Menu.");
                                                }
                                                else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                System.exit(0);
                                                }
                                                    }break;
                                                }break;
                                        }break;
     
                                    case '3':
     
                                        for (indexHouseA = 0; indexHouseA <=HouseA3.length; indexHouseA++) {
    					if (indexHouseA == 2) {
    						System.out.println();
                                                    System.out.println("Sorry, this house is full.");
                                                    System.out.println("Please look for another house");
                                                    System.out.println(" M - Back to Main Menu");
                                                    System.out.println(" Q - Quit ");
                                                    userChoiceFullA = keyboard.nextLine();
                                                    optionChoiceFullA = userChoiceFullA.charAt(0);
     
                                                    if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                    System.out.println();
                                                    System.out.println("Main Menu.");
                                                    }
                                                    else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                    System.exit(0);
                                                    }break;
                                                    }
     
                                            else if (HouseA3[indexHouseA] < 1){
                                                System.out.println();
                                                System.out.println("Which room do you want? (1/2)");
                                                userInputR1 = keyboard.nextLine();
                                                roomNumber = Integer.parseInt(userInputR1);
     
                                                if (roomNumber == 1){
                                                    if (HouseA3[roomNumber-1] == 0 ) {
                                                    HouseA3 [roomNumber-1] += 1;
                                                    nextA = true;
     
                                                    System.out.println("Thanks, your room is in room number "+roomNumber+", house "+houseNumber+" "+
                                                                       "on "+apartmentType1+".");
                                                    System.out.println("Please pay all the administration fees.");
                                                    System.out.println("You will be assigned till "+ assignDate +".");
                                                    }
                                                }
     
                                                else {
                                                nextA = false;
                                                System.out.println();
                                                System.out.println();
                                                System.out.println("Sorry, this room is already booked");
                                                System.out.println("Please look for another room");
                                                System.out.println(" M - Back to Main Menu");
                                                System.out.println(" Q - Quit ");
                                                userChoiceFullA = keyboard.nextLine();
                                                optionChoiceFullA = userChoiceFullA.charAt(0);
                                                if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                System.out.println();
                                                System.out.println("Main Menu.");
                                                }
                                                else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                System.exit(0);
                                                }
                                                    }break;
                                                }break;
                                        }break;
     
                                    case '4':
     
                                        for (indexHouseA = 0; indexHouseA <=HouseA4.length; indexHouseA++) {
    					if (indexHouseA == 2) {
    						System.out.println();
                                                    System.out.println("Sorry, this house is full.");
                                                    System.out.println("Please look for another house");
                                                    System.out.println(" M - Back to Main Menu");
                                                    System.out.println(" Q - Quit ");
                                                    userChoiceFullA = keyboard.nextLine();
                                                    optionChoiceFullA = userChoiceFullA.charAt(0);
     
                                                    if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                    System.out.println();
                                                    System.out.println("Main Menu.");
                                                    }
                                                    else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                    System.exit(0);
                                                    }break;
                                                    }
     
                                            else if (HouseA4[indexHouseA] < 1){
                                                System.out.println();
                                                System.out.println("Which room do you want? (1/2)");
                                                userInputR1 = keyboard.nextLine();
                                                roomNumber = Integer.parseInt(userInputR1);
     
                                                if (roomNumber == 1){
                                                    if (HouseA4[roomNumber-1] == 0 ) {
                                                    HouseA4 [roomNumber-1] += 1;
                                                    nextA = true;
     
                                                    System.out.println("Thanks, your room is in room number "+roomNumber+", house "+houseNumber+" "+
                                                                       "on "+apartmentType1+".");
                                                    System.out.println("Please pay all the administration fees.");
                                                    System.out.println("You will be assigned till "+ assignDate +".");
                                                    }
                                                }
     
                                                else {
                                                nextA = false;
                                                System.out.println();
                                                System.out.println();
                                                System.out.println("Sorry, this room is already booked");
                                                System.out.println("Please look for another room");
                                                System.out.println(" M - Back to Main Menu");
                                                System.out.println(" Q - Quit ");
                                                userChoiceFullA = keyboard.nextLine();
                                                optionChoiceFullA = userChoiceFullA.charAt(0);
                                                if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                System.out.println();
                                                System.out.println("Main Menu.");
                                                }
                                                else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                System.exit(0);
                                                }
                                                    }break;
                                                }break;
                                        }break;
     
                                    case '5':
     
                                        for (indexHouseA = 0; indexHouseA <=HouseA5.length; indexHouseA++) {
    					if (indexHouseA == 2) {
    						System.out.println();
                                                    System.out.println("Sorry, this house is full.");
                                                    System.out.println("Please look for another house");
                                                    System.out.println(" M - Back to Main Menu");
                                                    System.out.println(" Q - Quit ");
                                                    userChoiceFullA = keyboard.nextLine();
                                                    optionChoiceFullA = userChoiceFullA.charAt(0);
     
                                                    if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                    System.out.println();
                                                    System.out.println("Main Menu.");
                                                    }
                                                    else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                    System.exit(0);
                                                    }break;
                                                    }
     
                                            else if (HouseA5[indexHouseA] < 1){
                                                System.out.println();
                                                System.out.println("Which room do you want? (1/2)");
                                                userInputR1 = keyboard.nextLine();
                                                roomNumber = Integer.parseInt(userInputR1);
     
                                                if (roomNumber == 1){
                                                    if (HouseA5[roomNumber-1] == 0 ) {
                                                    HouseA5 [roomNumber-1] += 1;
                                                    nextA = true;
     
                                                    System.out.println("Thanks, your room is in room number "+roomNumber+", house "+houseNumber+" "+
                                                                       "on "+apartmentType1+".");
                                                    System.out.println("Please pay all the administration fees.");
                                                    System.out.println("You will be assigned till "+ assignDate +".");
                                                    }
                                                }
     
                                                else {
                                                nextA = false;
                                                System.out.println();
                                                System.out.println();
                                                System.out.println("Sorry, this room is already booked");
                                                System.out.println("Please look for another room");
                                                System.out.println(" M - Back to Main Menu");
                                                System.out.println(" Q - Quit ");
                                                userChoiceFullA = keyboard.nextLine();
                                                optionChoiceFullA = userChoiceFullA.charAt(0);
                                                if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                System.out.println();
                                                System.out.println("Main Menu.");
                                                }
                                                else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                System.exit(0);
                                                }
                                                    }break;
                                                }break;
                                        }break;
     
                                    }break;
                        }
                        else if(optionInputI == 'b' || optionInputI == 'B') {
                            apartmentType2 = "Apartment Type B";
     
                            System.out.println("Which house do you want?");
                                    System.out.println("#.  House");
                                    System.out.println("1     B1 ");
                                    System.out.println("2     B2 ");
                                    System.out.println("3     B3 ");
                                    System.out.println("4     B4 ");
                                    System.out.println("5     B5 ");
     
    				userInputR = keyboard.nextLine();
    				houseNumber = Integer.parseInt(userInputR);
     
                                    switch(houseNumber) {
     
                                    case '1' :
     
     
                                        for (indexHouseB = 0; indexHouseB <=HouseB1.length; indexHouseB++) {
    					if (indexHouseB == 3) {
    						System.out.println();
                                                    System.out.println("Sorry, this house is full.");
                                                    System.out.println("Please look for another house");
                                                    System.out.println(" M - Back to Main Menu");
                                                    System.out.println(" Q - Quit ");
                                                    userChoiceFullA = keyboard.nextLine();
                                                    optionChoiceFullA = userChoiceFullA.charAt(0);
     
                                                    if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                    System.out.println();
                                                    System.out.println("Main Menu.");
                                                    }
                                                    else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                    System.exit(0);
                                                    }break;
                                                    }
     
                                            else if (HouseB1[indexHouseB] < 1){
                                                System.out.println();
                                                System.out.println("Which room do you want? (1/2/3)");
                                                System.out.println(" *note = 3 is Master Bedroom");
                                                userInputR1 = keyboard.nextLine();
                                                roomNumber = Integer.parseInt(userInputR1);
     
                                                if (roomNumber == 1){
                                                    if (HouseB1[roomNumber-1] == 0 ) {
                                                    HouseB1 [roomNumber-1] += 1;
                                                    nextB = true;
     
                                                    System.out.println("Thanks, your room is in room number "+roomNumber+", house "+houseNumber+" "+
                                                                       "on "+apartmentType2+".");
                                                    System.out.println("Please pay all the administration fees.");
                                                    System.out.println("You will be assigned till "+ assignDate +".");
                                                    }
                                                }
     
                                                else {
                                                nextB = false;
                                                System.out.println();
                                                System.out.println();
                                                System.out.println("Sorry, this room is already booked");
                                                System.out.println("Please look for another room");
                                                System.out.println(" M - Back to Main Menu");
                                                System.out.println(" Q - Quit ");
                                                userChoiceFullA = keyboard.nextLine();
                                                optionChoiceFullA = userChoiceFullA.charAt(0);
                                                if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                System.out.println();
                                                System.out.println("Main Menu.");
                                                }
                                                else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                System.exit(0);
                                                }
                                                    }break;
                                                }break;
                                        }break;
     
                                    case '2' :
     
     
                                        for (indexHouseB = 0; indexHouseB <=HouseB2.length; indexHouseB++) {
    					if (indexHouseB == 3) {
    						System.out.println();
                                                    System.out.println("Sorry, this house is full.");
                                                    System.out.println("Please look for another house");
                                                    System.out.println(" M - Back to Main Menu");
                                                    System.out.println(" Q - Quit ");
                                                    userChoiceFullA = keyboard.nextLine();
                                                    optionChoiceFullA = userChoiceFullA.charAt(0);
     
                                                    if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                    System.out.println();
                                                    System.out.println("Main Menu.");
                                                    }
                                                    else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                    System.exit(0);
                                                    }break;
                                                    }
     
                                            else if (HouseB2[indexHouseB] < 1){
                                                System.out.println();
                                                System.out.println("Which room do you want? (1/2/3)");
                                                System.out.println(" *note = 3 is Master Bedroom");
                                                userInputR1 = keyboard.nextLine();
                                                roomNumber = Integer.parseInt(userInputR1);
     
                                                if (roomNumber == 1){
                                                    if (HouseB2[roomNumber-1] == 0 ) {
                                                    HouseB2 [roomNumber-1] += 1;
                                                    nextB = true;
     
                                                    System.out.println("Thanks, your room is in room number "+roomNumber+", house "+houseNumber+" "+
                                                                       "on "+apartmentType2+".");
                                                    System.out.println("Please pay all the administration fees.");
                                                    System.out.println("You will be assigned till "+ assignDate +".");
                                                    }
                                                }
     
                                                else {
                                                nextB = false;
                                                System.out.println();
                                                System.out.println();
                                                System.out.println("Sorry, this room is already booked");
                                                System.out.println("Please look for another room");
                                                System.out.println(" M - Back to Main Menu");
                                                System.out.println(" Q - Quit ");
                                                userChoiceFullA = keyboard.nextLine();
                                                optionChoiceFullA = userChoiceFullA.charAt(0);
                                                if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                System.out.println();
                                                System.out.println("Main Menu.");
                                                }
                                                else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                System.exit(0);
                                                }
                                                    }break;
                                                }break;
                                        }break;
     
                                    case '3' :
     
     
                                        for (indexHouseB = 0; indexHouseB <=HouseB3.length; indexHouseB++) {
    					if (indexHouseB == 3) {
    						System.out.println();
                                                    System.out.println("Sorry, this house is full.");
                                                    System.out.println("Please look for another house");
                                                    System.out.println(" M - Back to Main Menu");
                                                    System.out.println(" Q - Quit ");
                                                    userChoiceFullA = keyboard.nextLine();
                                                    optionChoiceFullA = userChoiceFullA.charAt(0);
     
                                                    if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                    System.out.println();
                                                    System.out.println("Main Menu.");
                                                    }
                                                    else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                    System.exit(0);
                                                    }break;
                                                    }
     
                                            else if (HouseB3[indexHouseB] < 1){
                                                System.out.println();
                                                System.out.println("Which room do you want? (1/2/3)");
                                                System.out.println(" *note = 3 is Master Bedroom");
                                                userInputR1 = keyboard.nextLine();
                                                roomNumber = Integer.parseInt(userInputR1);
     
                                                if (roomNumber == 1){
                                                    if (HouseB3[roomNumber-1] == 0 ) {
                                                    HouseB3 [roomNumber-1] += 1;
                                                    nextB = true;
     
                                                    System.out.println("Thanks, your room is in room number "+roomNumber+", house "+houseNumber+" "+
                                                                       "on "+apartmentType2+".");
                                                    System.out.println("Please pay all the administration fees.");
                                                    System.out.println("You will be assigned till "+ assignDate +".");
                                                    }
                                                }
     
                                                else {
                                                nextB = false;
                                                System.out.println();
                                                System.out.println();
                                                System.out.println("Sorry, this room is already booked");
                                                System.out.println("Please look for another room");
                                                System.out.println(" M - Back to Main Menu");
                                                System.out.println(" Q - Quit ");
                                                userChoiceFullA = keyboard.nextLine();
                                                optionChoiceFullA = userChoiceFullA.charAt(0);
                                                if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                System.out.println();
                                                System.out.println("Main Menu.");
                                                }
                                                else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                System.exit(0);
                                                }
                                                    }break;
                                                }break;
                                        }break;
     
                                    case '4' :
     
     
                                        for (indexHouseB = 0; indexHouseB <=HouseB4.length; indexHouseB++) {
    					if (indexHouseB == 3) {
    						System.out.println();
                                                    System.out.println("Sorry, this house is full.");
                                                    System.out.println("Please look for another house");
                                                    System.out.println(" M - Back to Main Menu");
                                                    System.out.println(" Q - Quit ");
                                                    userChoiceFullA = keyboard.nextLine();
                                                    optionChoiceFullA = userChoiceFullA.charAt(0);
     
                                                    if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                    System.out.println();
                                                    System.out.println("Main Menu.");
                                                    }
                                                    else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                    System.exit(0);
                                                    }break;
                                                    }
     
                                            else if (HouseB4[indexHouseB] < 1){
                                                System.out.println();
                                                System.out.println("Which room do you want? (1/2/3)");
                                                System.out.println(" *note = 3 is Master Bedroom");
                                                userInputR1 = keyboard.nextLine();
                                                roomNumber = Integer.parseInt(userInputR1);
     
                                                if (roomNumber == 1){
                                                    if (HouseB4[roomNumber-1] == 0 ) {
                                                    HouseB4 [roomNumber-1] += 1;
                                                    nextB = true;
     
                                                    System.out.println("Thanks, your room is in room number "+roomNumber+", house "+houseNumber+" "+
                                                                       "on "+apartmentType2+".");
                                                    System.out.println("Please pay all the administration fees.");
                                                    System.out.println("You will be assigned till "+ assignDate +".");
                                                    }
                                                }
     
                                                else {
                                                nextB = false;
                                                System.out.println();
                                                System.out.println();
                                                System.out.println("Sorry, this room is already booked");
                                                System.out.println("Please look for another room");
                                                System.out.println(" M - Back to Main Menu");
                                                System.out.println(" Q - Quit ");
                                                userChoiceFullA = keyboard.nextLine();
                                                optionChoiceFullA = userChoiceFullA.charAt(0);
                                                if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                System.out.println();
                                                System.out.println("Main Menu.");
                                                }
                                                else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                System.exit(0);
                                                }
                                                    }break;
                                                }break;
                                        }break;
     
                                    case '5' :
     
     
                                        for (indexHouseB = 0; indexHouseB <=HouseB5.length; indexHouseB++) {
    					if (indexHouseB == 3) {
    						System.out.println();
                                                    System.out.println("Sorry, this house is full.");
                                                    System.out.println("Please look for another house");
                                                    System.out.println(" M - Back to Main Menu");
                                                    System.out.println(" Q - Quit ");
                                                    userChoiceFullA = keyboard.nextLine();
                                                    optionChoiceFullA = userChoiceFullA.charAt(0);
     
                                                    if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                    System.out.println();
                                                    System.out.println("Main Menu.");
                                                    }
                                                    else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                    System.exit(0);
                                                    }break;
                                                    }
     
                                            else if (HouseB5[indexHouseB] < 1){
                                                System.out.println();
                                                System.out.println("Which room do you want? (1/2/3)");
                                                System.out.println(" *note = 3 is Master Bedroom");
                                                userInputR1 = keyboard.nextLine();
                                                roomNumber = Integer.parseInt(userInputR1);
     
                                                if (roomNumber == 1){
                                                    if (HouseB5[roomNumber-1] == 0 ) {
                                                    HouseB5 [roomNumber-1] += 1;
                                                    nextB = true;
     
                                                    System.out.println("Thanks, your room is in room number "+roomNumber+", house "+houseNumber+" "+
                                                                       "on "+apartmentType2+".");
                                                    System.out.println("Please pay all the administration fees.");
                                                    System.out.println("You will be assigned till "+ assignDate +".");
                                                    }
                                                }
     
                                                else {
                                                nextB = false;
                                                System.out.println();
                                                System.out.println();
                                                System.out.println("Sorry, this room is already booked");
                                                System.out.println("Please look for another room");
                                                System.out.println(" M - Back to Main Menu");
                                                System.out.println(" Q - Quit ");
                                                userChoiceFullA = keyboard.nextLine();
                                                optionChoiceFullA = userChoiceFullA.charAt(0);
                                                if (optionChoiceFullA == 'm' || optionChoiceFullA == 'M'){
                                                System.out.println();
                                                System.out.println("Main Menu.");
                                                }
                                                else if (optionChoiceFullA == 'q' || optionChoiceFullA == 'Q'){
                                                System.exit(0);
                                                }
                                                    }break;
                                                }break;
                                        }break;
     
                                    }break;
                        }
     
                        else {
                        next = false;
                        System.out.println();
                        System.out.println("Wrong type, Back to Main Menu");
                        System.out.println();
                        }break;
     
     
     
                    case 'v' : case 'V':     
                            System.out.println();
                            System.out.println(" VIEW ROOM OCCUPANCY ");
                            System.out.println("---------------------------------");
                            System.out.println("A - for Apartment A");
                            System.out.println("B - for Apartment B");
                            System.out.println("M - to return to Main Menu");
                            System.out.print("Enter : ");
                            userInputI = keyboard.nextLine();
                            optionInputI = userInputI.charAt(0);
                                if(optionInputI == 'M' || optionInputI == 'm') {
    				System.out.println();
    				System.out.println("Back to Main Menu.");
    				System.out.println();
                                }
                                else if(optionInputI == 'A' || optionInputI == 'a') {
                                    System.out.println();
    				System.out.print("Please choose a house number: (1 - 5)");
                                    userInputView = keyboard.nextLine();
                                    optionInputView = userInputView.charAt(0);
     
                                    switch (optionInputView){
                                        case '1' :
     
                                                System.out.println();
                                                System.out.println("************************************");
                                                System.out.println("*        Apartment A (House 1)      *");
                                                System.out.println("************************************");
                                                System.out.print("*");
     
                                                for(indexHouseA = 0; indexHouseA < HouseA1.length; indexHouseA++){
                                                    System.out.print("       " + HouseA1[indexHouseA]);
     
                                                    if(indexHouseA == 2){
                                                        System.out.print("                                             ");
                                                        System.out.println();
                                                        System.out.println("********************************************");
                                                        if(indexHouseA == 2){
                                                        System.out.println();
     
     
     
                                                    }
                                                    }
                                                }System.out.println();
                                                System.out.println();
                                                System.out.println("HINT :       ");
                                                System.out.println("[ 0 => available ]");
                                                System.out.println("[ 1 => reserved  ]");
                                                break;
     
                                        case '2' :
     
                                                System.out.println();
                                                System.out.println("************************************");
                                                System.out.println("*        Apartment A (House 2)      *");
                                                System.out.println("************************************");
                                                System.out.print("*");
                                                for(indexHouseA = 0; indexHouseA < HouseA2.length; indexHouseA++){
                                                    System.out.print("       " + HouseA2[indexHouseA]);
                                                    if(indexHouseA == 2){
                                                        System.out.print("                                             ");
                                                        System.out.println();
                                                        System.out.println("********************************************");
                                                        if(indexHouseA == 2){
                                                        System.out.println();
     
                                                    }
                                                    }
                                                }System.out.println();
                                                System.out.println();
                                                System.out.println("HINT :       ");
                                                System.out.println("[ 0 => available ]");
                                                System.out.println("[ 1 => reserved  ]");
                                                break;
     
     
                                        case '3' :
     
                                                System.out.println();
                                                System.out.println("************************************");
                                                System.out.println("*        Apartment A (House 3)      *");
                                                System.out.println("************************************");
                                                System.out.print("*");
                                                for(indexHouseA = 0; indexHouseA < HouseA3.length; indexHouseA++){
                                                    System.out.print("       " + HouseA3[indexHouseA]);
                                                    if(indexHouseA == 2){
                                                        System.out.print("                                             ");
                                                        System.out.println();
                                                        System.out.println("********************************************");
                                                        if(indexHouseA == 2){
                                                        System.out.println();
     
                                                    }
                                                    }
                                                }System.out.println();
                                                System.out.println();
                                                System.out.println("HINT :       ");
                                                System.out.println("[ 0 => available ]");
                                                System.out.println("[ 1 => reserved  ]");
                                                break;
     
                                        case '4' :
     
                                                System.out.println();
                                                System.out.println("************************************");
                                                System.out.println("*        Apartment A (House 4)      *");
                                                System.out.println("************************************");
                                                System.out.print("*");
                                                for(indexHouseA = 0; indexHouseA < HouseA4.length; indexHouseA++){
                                                    System.out.print("       " + HouseA4[indexHouseA]);
                                                    if(indexHouseA == 2){
                                                        System.out.print("                                             ");
                                                        System.out.println();
                                                        System.out.println("********************************************");
                                                        if(indexHouseA == 2){
                                                        System.out.println();
     
                                                    }
                                                    }
                                                }System.out.println();
                                                System.out.println();
                                                System.out.println("HINT :       ");
                                                System.out.println("[ 0 => available ]");
                                                System.out.println("[ 1 => reserved  ]");
                                                break;
     
                                        case '5' :
     
                                                System.out.println();
                                                System.out.println("************************************");
                                                System.out.println("*        Apartment A (House 5)      *");
                                                System.out.println("************************************");
                                                System.out.print("*");
                                                for(indexHouseA = 0; indexHouseA < HouseA5.length; indexHouseA++){
                                                    System.out.print("       " + HouseA5[indexHouseA]);
                                                    if(indexHouseA == 2){
                                                        System.out.print("                                             ");
                                                        System.out.println();
                                                        System.out.println("********************************************");
                                                        if(indexHouseA == 2){
                                                        System.out.println();
     
                                                    }
                                                    }
                                                }System.out.println();
                                                System.out.println();
                                                System.out.println("HINT :       ");
                                                System.out.println("[ 0 => available ]");
                                                System.out.println("[ 1 => reserved  ]");
                                                break;    
     
                                    }break;
                                }
     
                                else if(optionInputI == 'b' || optionInputI == 'B') {
                                    System.out.println();
    				System.out.print("Please choose a house number: (1 - 5)");
                                    userInputView = keyboard.nextLine();
                                    optionInputView = userInputView.charAt(0);
     
                                    switch (optionInputView){
                                        case '1' :
     
                                                System.out.println();
                                                System.out.println("*************************************");
                                                System.out.println("*          Apartment B (House 1)    *");
                                                System.out.println("*************************************");
                                                System.out.print("*");
                                                for(indexHouseB = 0; indexHouseB < HouseB1.length; indexHouseB++){
                                                    System.out.print("       " + HouseB1[indexHouseB]);
                                                    if(indexHouseB == 3){
                                                        System.out.print("                                          *");
                                                        System.out.println();
                                                        System.out.println("*****************************************");
                                                        System.out.println();
     
                                                    }
     
     
                                                }System.out.println();
                                                System.out.println("HINT :       ");
                                                System.out.println("[ 0 => available ]");
                                                System.out.println("[ 1 => reserved  ]");
                                                break;
     
                                        case '2' :
     
                                                System.out.println();
                                                System.out.println("*************************************");
                                                System.out.println("*          Apartment B (House 2)    *");
                                                System.out.println("*************************************");
                                                System.out.print("*");
                                                for(indexHouseB = 0; indexHouseB < HouseB2.length; indexHouseB++){
                                                    System.out.print("       " + HouseB2[indexHouseB]);
                                                    if(indexHouseB == 3){
                                                        System.out.print("                                          *");
                                                        System.out.println();
                                                        System.out.println("*****************************************");
                                                        System.out.println();
     
                                                    }
     
     
                                                }
                                                System.out.println();
                                                System.out.println("HINT :       ");
                                                System.out.println("[ 0 => available ]");
                                                System.out.println("[ 1 => reserved  ]");
                                                break;
     
                                        case '3' :
     
                                                System.out.println();
                                                System.out.println("*************************************");
                                                System.out.println("*          Apartment B (House 3)    *");
                                                System.out.println("*************************************");
                                                System.out.print("*");
                                                for(indexHouseB = 0; indexHouseB < HouseB3.length; indexHouseB++){
                                                    System.out.print("       " + HouseB3[indexHouseB]);
                                                    if(indexHouseB == 3){
                                                        System.out.print("                                          *");
                                                        System.out.println();
                                                        System.out.println("*****************************************");
                                                        System.out.println();
     
                                                    }
     
     
                                                }System.out.println();
                                                System.out.println("HINT :       ");
                                                System.out.println("[ 0 => available ]");
                                                System.out.println("[ 1 => reserved  ]");
                                                break;
     
                                         case '4' :
     
                                                System.out.println();
                                                System.out.println("*************************************");
                                                System.out.println("*          Apartment B (House 4)    *");
                                                System.out.println("*************************************");
                                                System.out.print("*");
                                                for(indexHouseB = 0; indexHouseB < HouseB4.length; indexHouseB++){
                                                    System.out.print("       " + HouseB4[indexHouseB]);
                                                    if(indexHouseB == 3){
                                                        System.out.print("                                          *");
                                                        System.out.println();
                                                        System.out.println("*****************************************");
                                                        System.out.println();
     
                                                    }
     
     
                                                }System.out.println();
                                                System.out.println("HINT :       ");
                                                System.out.println("[ 0 => available ]");
                                                System.out.println("[ 1 => reserved  ]");
                                                break;
     
                                         case '5' :
     
                                                System.out.println();
                                                System.out.println("*************************************");
                                                System.out.println("*          Apartment B (House 5)    *");
                                                System.out.println("*************************************");
                                                System.out.print("*");
                                                for(indexHouseB = 0; indexHouseB < HouseB5.length; indexHouseB++){
                                                    System.out.print("       " + HouseB5[indexHouseB]);
                                                    if(indexHouseB == 3){
                                                        System.out.print("                                          *");
                                                        System.out.println();
                                                        System.out.println("*****************************************");
                                                        System.out.println();
     
                                                    }
     
     
                                                }System.out.println();
                                                System.out.println("HINT :       ");
                                                System.out.println("[ 0 => available ]");
                                                System.out.println("[ 1 => reserved  ]");
                                                break;
                                    }break;
                                }
     
                                else {
                                next = false;
                                System.out.println();
                                System.out.println("Wrong type, Back to Main Menu");
                                System.out.println();
                                }break;
     
     
                   case 's' : case 'S' :
                        System.out.println();
                        System.out.println("Insert Full Student ID number (ex: TP123456");
                        System.out.println();
     
     
     
     
     
                   case 'q' : case 'Q' :
                        System.out.println();
                        System.out.println("You quit the system");
                        System.exit(0);
                        break;
     
     
                   default :
                        System.out.println();
                        System.out.println("Wrong type, back to Main Menu.");
                        break;
     
                }       
     
     
            }while( optionMain != 'q' || optionMain != 'Q');
            }
    }

  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: help me please..

    You never replied to my question in your last thread, and you never replied to *any* answers to your first thread. Sorry, but it can be de-motivating to a volunteer if they feel their help is being ignored, that they're wasting energy and time for no reason as it begs the question how will we know if you'll read and reply to help in this thread?

    Did you resolve the issue from the previous threads? If so, please don't leave us hanging; please let us know. Or is the issue still not solved? If not, please let us know that too and anything that we can do to help you solve it.

    Regarding the current problem, I think that you'll need to tell us more about the problem as you've posted quite a lot of code and only have given us a small bit of explanation. Also, what steps have you taken to debug the problem? Are you using a debugger or using println statements to help debug?

  3. #3
    Member
    Join Date
    Jul 2012
    Posts
    71
    Thanks
    1
    Thanked 7 Times in 7 Posts

    Default Re: help me please..

    wow that's a lot of code to just be a main method u should break some of the stuff you've written down (like every option choice) into separate classes.... makes it easier for others to read.... i can see from it that the reason you can't book another room in the house is because of "else if (roomNumber == 2){if (HouseA1[roomNumber-2] < 2 ) {HouseA1 [roomNumber-2] += 1;...." when u enter 2 the program executes HouseA1[roomNumber-2] which is HouseA1[0] which is already booked

  4. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: help me please..

    And you still haven't replied to the previous posts or the current ones. I was hoping that you would have proved me wrong in this and would have shown all what a great guy you were by acknowledging all the contributions that have been posted in your threads in an attempt to help you be a better coder, and yet you still disappoint me.

    Please surprise me by rectifying this problem. I know you can do it. I know that we can transform you into a model forum citizen.

    With hope, Curmudgeon.