12 Replies - 2473 Views - Last Post: 17 November 2012 - 07:46 PM Rate Topic: -----

#1 Zakii  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 15-November 12

java.lang.String.charAt(String.java:658)

Posted 15 November 2012 - 09:38 AM

I have no idea what wrong with the code..
Its say that illegal start of expression and while expected at the end of the code..

Any help will be much appreciated.. :)/>/>




import java.text.*;
import java.util.*;

public class University_Apartment
{
    public static void main (String[]arguments)
    {
        String studentName, studentID, passportNumber;
        String userInputMain, userInput1,userInput2, userInput3, userChoiceA, userChoiceFull, userChoiceFullA, apartmentType, register;
        String inputView1;
        String currentDate, assignDate, currentHour;
        char optionMain, optionInput1, optionInput2, optionInput3, optionChoiceA, optionChoiceFull, optionChoiceFullA, choiceView1;
        int index, index1, index2, houseNumber, roomNumber, ID;
        
        final int apartTypeA = 2;
	final int apartTypeB = 2;
	final int roomA = 2;
	final int roomB = 3;
        boolean next = false;
        boolean next1 = false;
        
        String [] apartmentA = { "FloorA1", "FloorA2"};
	String [] apartmentB = { "FloorB1", "FloorB2"};
       
        
	int[] FloorA1 = new int[apartTypeA];
	int[] FloorA2 = new int[apartTypeA];
	
	int[] FloorB1 = new int[apartTypeB];
	int[] FloorB2 = new int[apartTypeB];
	
	
	int[] HouseA1 = new int[roomA];
	int[] HouseA2 = new int[roomA];
	int[] HouseB1 = new int[roomB];
	int[] HouseB2 = new int[roomB];
        
        Scanner keyboard = new Scanner (System.in);
        
        do {
        System.out.println("+++++++++++++++++++++++++++++++++");
	System.out.println("Fortes Fortuna Apartment");
	System.out.println("+++++++++++++++++++++++++++++++++");
	System.out.println("Main Menu");
	System.out.println("---------------------------------");
        System.out.println("I - to Apartment Info");
	System.out.println("R - to Register New Student");
	System.out.println("V - to View Occupancy");
	System.out.println("Q - to Quit the system");
        userInputMain = keyboard.nextLine();
	optionMain = userInputMain.charAt(0);
        
	switch(optionMain)
	{
              case 'i' : case 'I':
			
                   System.out.println("    APARTMENT INFORMATION");
                   System.out.println("---------------------------------");
                   System.out.println("A - Info Apartment A");
                   System.out.println("B - Info Apartment B");
                   System.out.println("M - to return to Main Menu");
                   System.out.print("Enter : ");
                   userInput1 = keyboard.nextLine();
                   optionInput1 = userInput1.charAt(0);
			
                        if(optionInput1 == 'M' || optionInput1 == 'm') {
                            System.out.println();
                            System.out.println("Back to Main Menu.");
                            System.out.println();
                            }
                        else if(optionInput1 == 'A' || optionInput1 == 'a') {
                            System.out.println("+++++++++ Apartment Type A +++++++++++");			
                            System.out.println("2 bedrooms");
                            System.out.println("Equipped with kitchen and laundry facilities");
                            System.out.println("Monthly rental = RM300.");
                            System.out.println("  M    - Return to main menu");
                            }
                        else if (optionInput1 == 'B' || optionInput1 == 'b') {
                            System.out.println("+++++++++ Apartment Type B +++++++++++");
                            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("*Master bedroom attached with inside bathroom");
                            System.out.println("**People who live in master bedroom will be paying 40% more = RM280");
                            }
                
                    
              case 'r': case 'R':
                    
                    System.out.println("    Register New Student");
                    System.out.println("---------------------------------");
                    System.out.println("Enter your name :");
                    studentName = keyboard.nextLine();
                              
                    System.out.println("Enter your Student ID :");
                    studentID = keyboard.nextLine();
                                
                    System.out.println("Enter your Passport Number :");
                    passportNumber = keyboard.nextLine();
                                
                    System.out.println("Which apartment type you want? (A/B)/>/>/>");
                    userInput2 = keyboard.nextLine();
                    optionInput2 = userInput2.charAt(0);
                              
                    switch(optionInput2)
                    {
                        case 'A':
                        apartmentA:
                        for (index = 0; index <=apartmentA.length; index++) {
                                if (index == 2) {
                                    System.out.println("Sorry, all houses are full.");
                                    System.out.println("Please look for another floor");
                                    System.out.println(" M - Back to Main Menu");
                                    System.out.println(" Q - Quit ");
                                    userChoiceA = keyboard.nextLine();
                                    optionChoiceA = userChoiceA.charAt(0);
                                    
                                        if (optionChoiceA == 'm' || optionChoiceA == 'M'){
                                            System.out.println();
                                            System.out.println("Main Menu.");
                                            }
                                        else if (optionChoiceA == 'q' || optionChoiceA == 'Q'){
                                            System.exit(0);
                                            }
                                            break;}
                                                                 
                                else if (FloorA1[index] < 1){
                                    System.out.println("What floor do you want? (1/2)");
                                    userInput3 = keyboard.nextLine();
                                    optionInput3 = userInput3.charAt(0);
                        
                                    switch(optionInput3)
                                    {
                                        case '1':
                                            apartmentType = "Apartment Type A";
                                            for (index1 = 0; index1 <=FloorA1.length; index1++) {
                                                if (index1 == 2) {
                                                    System.out.println("Sorry, all houses are full.");
                                                    System.out.println("Please look for another floor");
                                                    System.out.println(" M - Back to Main Menu");
                                                    System.out.println(" Q - Quit ");
                                                    userChoiceA = keyboard.nextLine();
                                                    optionChoiceA = userChoiceA.charAt(0);
                                                        if (optionChoiceA == 'm' || optionChoiceA == 'M'){
                                                            System.out.println();
                                                            System.out.println("Main Menu.");
                                                            }
                                                        else if (optionChoiceA == 'q' || optionChoiceA == 'Q'){
                                                            System.exit(0);
                                                            }
                                    
                                                else if (FloorA1[index1] < 1){
                                                    System.out.println("Please choose house");
                                                    System.out.println("C - choose house number");
                                                    System.out.println("R - pick a random house");
                                                    System.out.print("Enter your choice = ");
                                                    userChoiceA = keyboard.nextLine();
                                                    optionChoiceA = userChoiceA.charAt(0);
                                                        if (optionChoiceA == 'c' ||  optionChoiceA == 'C'){
                                                            System.out.print("Enter house number you want (1/2)= ");
                                                            houseNumber = keyboard.nextInt();
                                                    
                                                                if ((houseNumber >= 1) && (houseNumber <= 2)) {
                                                                            if(FloorA1[houseNumber-1] == 0 ) {
                                                                                FloorA1[houseNumber-1] += 1;
                                                                                System.out.println("Enter room number you want(1-2)= ");
                                                                                roomNumber = keyboard.nextInt();
                                                            
                                                                                    if ((roomNumber >= 1) && (roomNumber <= 2)) {
                                                                                            if (HouseA1[roomNumber-1] == 0 ) {
                                                                                                HouseA1 [roomNumber-1] += 1;
                                                                                                next1 = true;
                                                                               
                                                                                                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("Thanks, your room is in room "+ roomNumber +", house number"+
                                                                                                            houseNumber +", 1st floor on "+ apartmentType);
                                                                                                break;
                                                                                                }
                                                                                
                                                                                            else {
                                                                                                next1 = false;
                                                                                                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;
                                                                                                    }   
                                                                                            }
                                                                                    else {								
                                                                                        System.out.println();
                                                                                        System.out.println("Wrong Type, Back to Main Menu");
                                                                                        next1 = false;
                                                                                        break;
                                                                                        }
                                                                            }
                                                            
                                                                            else {								
                                                                                System.out.println();
                                                                                System.out.println("Wrong Type, Back to Main Menu"); 
                                                                                next = false;
                                                                                break;
                                                                                }
                                                                            }
                                                                }
                                                                else {
                                                                    next = false;
                                                                    System.out.println();
                                                                    System.out.println("Sorry, these rooms are already booked");
                                                                    System.out.println("Please look for another room");
                                                                    System.out.println(" M - Back to Main Menu");
                                                                    System.out.println(" Q - Quit ");
                                                                    userChoiceFull = keyboard.nextLine();
                                                                    optionChoiceFull = userChoiceFull.charAt(0);
                                                    
                                                                        if (optionChoiceFull == 'm' || optionChoiceFull == 'M'){
                                                                            System.out.println();
                                                                            System.out.println("Main Menu.");
                                                                            }
                                                                        else if (optionChoiceFull == 'q' || optionChoiceFull == 'Q'){
                                                                            System.exit(0);
                                                                            }								
                                                                          break;
                                                                        }
                                                }
                                                        
                                                        else if (optionChoiceA == 'r' || optionChoiceA == 'R') {								
                                                                for ( index1 = 0; index1 < 2 ; index1++ ) {
                                                                        if (FloorA1[index1] == 0 ) {											
                                                                            FloorA1[index1] += 1;
                                                                            houseNumber = index1;
                                                                            houseNumber += 1;
                                                                            next1 = true;
                                                                            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("Thanks, your room is in room "+ roomNumber +", house number"+
                                                                                                houseNumber +", 1st floor on "+ apartmentType);
                                                                            break;
								}
                                                                }
                                                        }
                                                                else {								
							System.out.println();
							System.out.println("Invalid choice");
							System.out.println("Back to Main Menu"); 
							System.out.println();
							next = false;
							break;
						}
                                                }
                                                }
                                        
                                        break;
                                        
                                        
                                        case '2':
                                            apartmentType = "Apartment Type A";
                                            for (index1 = 0; index1 <=FloorA2.length; index1++) {
                                                if (index1 == 2) {
                                                    System.out.println("Sorry, all houses are full.");
                                                    System.out.println("Please look for another floor");
                                                    System.out.println(" M - Back to Main Menu");
                                                    System.out.println(" Q - Quit ");
                                                    userChoiceA = keyboard.nextLine();
                                                    optionChoiceA = userChoiceA.charAt(0);
                                                        if (optionChoiceA == 'm' || optionChoiceA == 'M'){
                                                            System.out.println();
                                                            System.out.println("Main Menu.");
                                                            }
                                                        else if (optionChoiceA == 'q' || optionChoiceA == 'Q'){
                                                            System.exit(0);
                                                            }
                                    
                                                else if (FloorA2[index1] < 1){
                                                    System.out.println("Please choose house");
                                                    System.out.println("C - choose house number");
                                                    System.out.println("R - pick a random house");
                                                    System.out.print("Enter your choice = ");
                                                    userChoiceA = keyboard.nextLine();
                                                    optionChoiceA = userChoiceA.charAt(0);
                                                        if (optionChoiceA == 'c' ||  optionChoiceA == 'C'){
                                                            System.out.print("Enter house number you want (1/2)= ");
                                                            houseNumber = keyboard.nextInt();
                                                    
                                                                if ((houseNumber >= 1) && (houseNumber <= 2)) {
                                                                            if(FloorA2[houseNumber-1] == 0 ) {
                                                                                FloorA2[houseNumber-1] += 1;
                                                                                System.out.println("Enter room number you want(1/2)= ");
                                                                                roomNumber = keyboard.nextInt();
                                                            
                                                                                    if ((roomNumber >= 1) && (roomNumber <= 2)) {
                                                                                            if (HouseA2[roomNumber-1] == 0 ) {
                                                                                                HouseA2 [roomNumber-1] += 1;
                                                                                                next1 = true;
                                                                               
                                                                                                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("Thanks, your room is in room "+ roomNumber +", house number"+
                                                                                                            houseNumber +", 1st floor on "+ apartmentType);
                                                                                                break;
                                                                                                }
                                                                                
                                                                                            else {
                                                                                                next1 = false;
                                                                                                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;
                                                                                                    }   
                                                                                            }
                                                                                    else {								
                                                                                        System.out.println();
                                                                                        System.out.println("Wrong Type, Back to Main Menu"); 
                                                                                        next = false;
                                                                                        break;
                                                                                        }
                                                                            }
                                                            
                                                                            else {								
                                                                                System.out.println();
                                                                                System.out.println("Wrong Type, Back to Main Menu"); 
                                                                                next = false;
                                                                                break;
                                                                                }
                                                                            }
                                                                }
                                                                else {
                                                                    next = false;
                                                                    System.out.println();
                                                                    System.out.println("Sorry, these rooms are already booked");
                                                                    System.out.println("Please look for another room");
                                                                    System.out.println(" M - Back to Main Menu");
                                                                    System.out.println(" Q - Quit ");
                                                                    userChoiceFull = keyboard.nextLine();
                                                                    optionChoiceFull = userChoiceFull.charAt(0);
                                                    
                                                                        if (optionChoiceFull == 'm' || optionChoiceFull == 'M'){
                                                                            System.out.println();
                                                                            System.out.println("Main Menu.");
                                                                            }
                                                                        else if (optionChoiceFull == 'q' || optionChoiceFull == 'Q'){
                                                                            System.exit(0);
                                                                            }								
                                                                          break;
                                                                        }
                                                }
                                                        
                                                        else if (optionChoiceA == 'r' || optionChoiceA == 'R') {								
                                                                for ( index1 = 0; index1 < 2 ; index1++ ) {
                                                                        if (FloorA1[index1] == 0 ) {											
                                                                            FloorA1[index1] += 1;
                                                                            houseNumber = index1;
                                                                            houseNumber += 1;
                                                                            next1 = true;
                                                                            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("Thanks, your room is in room "+ roomNumber +", house number"+
                                                                                                houseNumber +", 1st floor on "+ apartmentType);
                                                                            break;
								}
                                                                }
                                                        }
                                                        else {								
							System.out.println();
							System.out.println("Invalid choice");
							System.out.println("Back to Main Menu"); 
							System.out.println();
							next = false;
							break;
						}
                                                }
                                                }
                                        
                                        break;                                        
                                        
                              
                        case 'B':
                        apartmentB:
                        for (index = 0; index <=apartmentB.length; index++) {
                                if (index == 2) {
                                    System.out.println("Sorry, all houses are full.");
                                    System.out.println("Please look for another floor");
                                    System.out.println(" M - Back to Main Menu");
                                    System.out.println(" Q - Quit ");
                                    userChoiceA = keyboard.nextLine();
                                    optionChoiceA = userChoiceA.charAt(0);
                                    
                                        if (optionChoiceA == 'm' || optionChoiceA == 'M'){
                                            System.out.println();
                                            System.out.println("Main Menu.");
                                            }
                                        else if (optionChoiceA == 'q' || optionChoiceA == 'Q'){
                                            System.exit(0);
                                            }
                                            break;}
                                                                 
                                else if (FloorB1[index] < 1){
                                    System.out.println("What floor do you want? (1/2)");
                                    userInput3 = keyboard.nextLine();
                                    optionInput3 = userInput3.charAt(0);
                        
                                    switch(optionInput3)
                                    {
                                        case '1':
                                            apartmentType = "Apartment Type B";
                                            for (index2 = 0; index2 <=FloorB1.length; index2++) {
                                                if (index2 == 2) {
                                                    System.out.println("Sorry, all houses are full.");
                                                    System.out.println("Please look for another floor");
                                                    System.out.println(" M - Back to Main Menu");
                                                    System.out.println(" Q - Quit ");
                                                    userChoiceA = keyboard.nextLine();
                                                    optionChoiceA = userChoiceA.charAt(0);
                                                        if (optionChoiceA == 'm' || optionChoiceA == 'M'){
                                                            System.out.println();
                                                            System.out.println("Main Menu.");
                                                            }
                                                        else if (optionChoiceA == 'q' || optionChoiceA == 'Q'){
                                                            System.exit(0);
                                                            }
                                    
                                                else if (FloorB1[index2] < 1){
                                                    System.out.println("Please choose house");
                                                    System.out.println("C - choose house number");
                                                    System.out.println("R - pick a random house");
                                                    System.out.print("Enter your choice = ");
                                                    userChoiceA = keyboard.nextLine();
                                                    optionChoiceA = userChoiceA.charAt(0);
                                                        if (optionChoiceA == 'c' ||  optionChoiceA == 'C'){
                                                            System.out.print("Enter house number you want (1/2)= ");
                                                            houseNumber = keyboard.nextInt();
                                                    
                                                                if ((houseNumber >= 1) && (houseNumber <= 2)) {
                                                                            if(FloorB1[houseNumber-1] == 0 ) {
                                                                                FloorB1[houseNumber-1] += 1;
                                                                                System.out.println("Enter room number you want(1-2)= ");
                                                                                roomNumber = keyboard.nextInt();
                                                            
                                                                                    if ((roomNumber >= 1) && (roomNumber <= 2)) {
                                                                                            if (HouseB1[roomNumber-1] == 0 ) {
                                                                                                HouseB1 [roomNumber-1] += 1;
                                                                                                next1 = true;
                                                                               
                                                                                                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("Thanks, your room is in room "+ roomNumber +", house number"+
                                                                                                            houseNumber +", 1st floor on "+ apartmentType);
                                                                                                break;
                                                                                                }
                                                                                
                                                                                            else {
                                                                                                next1 = false;
                                                                                                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;
                                                                                                    }   
                                                                                            }
                                                                                    else {								
                                                                                        System.out.println();
                                                                                        System.out.println("Wrong Type, Back to Main Menu"); 
                                                                                        next = false;
                                                                                        break;
                                                                                        }
                                                                            }
                                                            
                                                                            else {								
                                                                                System.out.println();
                                                                                System.out.println("Wrong Type, Back to Main Menu"); 
                                                                                next = false;
                                                                                break;
                                                                                }
                                                                            }
                                                                }
                                                                else {
                                                                    next = false;
                                                                    System.out.println();
                                                                    System.out.println("Sorry, these rooms are already booked");
                                                                    System.out.println("Please look for another room");
                                                                    System.out.println(" M - Back to Main Menu");
                                                                    System.out.println(" Q - Quit ");
                                                                    userChoiceFull = keyboard.nextLine();
                                                                    optionChoiceFull = userChoiceFull.charAt(0);
                                                    
                                                                        if (optionChoiceFull == 'm' || optionChoiceFull == 'M'){
                                                                            System.out.println();
                                                                            System.out.println("Main Menu.");
                                                                            }
                                                                        else if (optionChoiceFull == 'q' || optionChoiceFull == 'Q'){
                                                                            System.exit(0);
                                                                            }								
                                                                          break;
                                                                        }
                                                }
                                                        
                                                        else if (optionChoiceA == 'r' || optionChoiceA == 'R') {								
                                                                for ( index2 = 0; index2 < 2 ; index2++ ) {
                                                                        if (FloorA1[index2] == 0 ) {											
                                                                            FloorA1[index2] += 1;
                                                                            houseNumber = index2;
                                                                            houseNumber += 1;
                                                                            next = true;
                                                                            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("Thanks, your room is in room "+ roomNumber +", house number"+
                                                                                                houseNumber +", 1st floor on "+ apartmentType);
                                                                            break;
								}
                                                                }
                                                        }
                                                                else {								
							System.out.println();
							System.out.println("Invalid choice");
							System.out.println("Back to Main Menu"); 
							System.out.println();
							next = false;
							break;
						}
                                                }
                                                }
                                        
                                        break;
                                        
                                        
                                        case '2':
                                            apartmentType = "Apartment Type B";
                                            for (index2 = 0; index2 <=FloorB2.length; index2++) {
                                                if (index2 == 2) {
                                                    System.out.println("Sorry, all houses are full.");
                                                    System.out.println("Please look for another floor");
                                                    System.out.println(" M - Back to Main Menu");
                                                    System.out.println(" Q - Quit ");
                                                    userChoiceA = keyboard.nextLine();
                                                    optionChoiceA = userChoiceA.charAt(0);
                                                        if (optionChoiceA == 'm' || optionChoiceA == 'M'){
                                                            System.out.println();
                                                            System.out.println("Main Menu.");
                                                            }
                                                        else if (optionChoiceA == 'q' || optionChoiceA == 'Q'){
                                                            System.exit(0);
                                                            }
                                    
                                                else if (FloorB2[index2] < 1){
                                                    System.out.println("Please choose house");
                                                    System.out.println("C - choose house number");
                                                    System.out.println("R - pick a random house");
                                                    System.out.print("Enter your choice = ");
                                                    userChoiceA = keyboard.nextLine();
                                                    optionChoiceA = userChoiceA.charAt(0);
                                                        if (optionChoiceA == 'c' ||  optionChoiceA == 'C'){
                                                            System.out.print("Enter house number you want (1/2)= ");
                                                            houseNumber = keyboard.nextInt();
                                                    
                                                                if ((houseNumber >= 1) && (houseNumber <= 2)) {
                                                                            if(FloorB2[houseNumber-1] == 0 ) {
                                                                                FloorB2[houseNumber-1] += 1;
                                                                                System.out.println("Enter room number you want(1/2)= ");
                                                                                roomNumber = keyboard.nextInt();
                                                            
                                                                                    if ((roomNumber >= 1) && (roomNumber <= 2)) {
                                                                                            if (HouseB2[roomNumber-1] == 0 ) {
                                                                                                HouseB2 [roomNumber-1] += 1;
                                                                                                next1 = true;
                                                                               
                                                                                                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("Thanks, your room is in room "+ roomNumber +", house number"+
                                                                                                            houseNumber +", 1st floor on "+ apartmentType);
                                                                                                break;
                                                                                                }
                                                                                
                                                                                            else {
                                                                                                next1 = false;
                                                                                                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;
                                                                                                    }   
                                                                                            }
                                                                                    else {								
                                                                                        System.out.println();
                                                                                        System.out.println("Wrong Type, Back to Main Menu"); 
                                                                                        next = false;
                                                                                        break;
                                                                                        }
                                                                            }
                                                                            else {								
                                                                                System.out.println();
                                                                                System.out.println("Wrong Type, Back to Main Menu"); 
                                                                                next = false;
                                                                                break;
                                                                                }
                                                                            }
                                                                }
                                                                else {
                                                                    next = false;
                                                                    System.out.println();
                                                                    System.out.println("Sorry, these rooms are already booked");
                                                                    System.out.println("Please look for another room");
                                                                    System.out.println(" M - Back to Main Menu");
                                                                    System.out.println(" Q - Quit ");
                                                                    userChoiceFull = keyboard.nextLine();
                                                                    optionChoiceFull = userChoiceFull.charAt(0);
                                                    
                                                                        if (optionChoiceFull == 'm' || optionChoiceFull == 'M'){
                                                                            System.out.println();
                                                                            System.out.println("Main Menu.");
                                                                            }
                                                                        else if (optionChoiceFull == 'q' || optionChoiceFull == 'Q'){
                                                                            System.exit(0);
                                                                            }								
                                                                          break;
                                                                        }
                                                }
                                                        
                                                        else if (optionChoiceA == 'r' || optionChoiceA == 'R') {								
                                                                for ( index2 = 0; index2 < 2 ; index2++ ) {
                                                                        if (FloorA1[index2] == 0 ) {											
                                                                            FloorA1[index2] += 1;
                                                                            houseNumber = index2;
                                                                            houseNumber += 1;
                                                                            next1 = true;
                                                                            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("Thanks, your room is in room "+ roomNumber +", house number"+
                                                                                                houseNumber +", 1st floor on "+ apartmentType);
                                                                            break;
								}
                                                                }
                                                        }
                                                        else {								
							System.out.println();
							System.out.println("Invalid choice");
							System.out.println("Back to Main Menu"); 
							System.out.println();
							next = false;
							break;
						}
                                                }
                                                }
                                        
                                        break;
                                        
                                        
                                            
                            
                        case 'v' : case 'V':     
                         
                            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 : ");
                            userInput1 = keyboard.nextLine();
                            optionInput1 = userInput1.charAt(0);
                            if(optionInput1 == 'M' || optionInput1 == 'm') {
				System.out.println();
				System.out.println("Back to Main Menu.");
				System.out.println();
                            }
                            else if(optionInput1 == 'A' || optionInput1 == 'a') {
				System.out.print("Please choose a floor number: (1-10)");
                                inputView1 = keyboard.nextLine();
                                choiceView1 = inputView1.charAt(0);
			
                                switch (choiceView1){
                                    case '1' :
                                    ID = 1;
                                            System.out.println("*************************************************");
                                            System.out.println("*               Apartment Type A                *");
                                            System.out.println("*************************************************");
                                            System.out.print("*");
                                            for(index1 = 0; index1 < FloorA1.length; index1++){
                                                System.out.print("       " + FloorA1[index1]);
                                                if(index1 == 2){
                                                    System.out.print("       *");
                                                    System.out.println();
                                                    System.out.println("*************************************************");
                                                    System.out.print("*");
                                                }
                                            }
                                            System.out.print("       *");
                                            System.out.println();
                                            System.out.println("*************************************************");
                                            System.out.println("*                Apartment Type B               *");
                                            System.out.println("*************************************************");
                                            System.out.print("*");
                                            for(index2 = 1; index2 < (FloorB1.length + 1); index2++){
                                                    System.out.print("       " + FloorB2[(index2-1)]);
                                                if(index2 % 5 == 0){
                                                    System.out.print("       *");
                                                    System.out.println();
                                                    System.out.println("*************************************************");
                                                    if(index2 / 5 == 0){
                                                        System.out.print("*");
                                                    }
                                                }
                                            }           
                                System.out.println();
                                break;
                                }
                        break;
                            }
                            
                            
                        case 'q' : case 'Q' :
			System.out.println("You quit the system");
			System.exit(0);
			break;
		
                        default :
			System.out.println("Wrong type, back to Main Menu.");
			break;
                }       while( optionMain != 'q' || optionMain != 'Q');
        
	
   }
                        }
                                    }
                                }
                        }
                    }
        }
        }
        }
}

                          



Is This A Good Question/Topic? 0
  • +

Replies To: java.lang.String.charAt(String.java:658)

#2 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 497
  • View blog
  • Posts: 3,313
  • Joined: 12-January 10

Re: java.lang.String.charAt(String.java:658)

Posted 15 November 2012 - 09:40 AM

post the error
Was This Post Helpful? 0
  • +
  • -

#3 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7995
  • View blog
  • Posts: 13,690
  • Joined: 19-March 11

Re: java.lang.String.charAt(String.java:658)

Posted 15 November 2012 - 09:46 AM

I'm not going to try to navigate all of that, but I can tell you that the compiler got to the closing brace that should have ended your do..while loop, and it didn't find a while clause. This means you've lost control of your braces somewhere.

This is not surprising in an 800-line method consisting entirely of switches and if blocks.
This badly needs to be refactored. Start by moving decisions out to methods. This will probably help you find the bug.
Then get rid of any "if" that simply decides what text to show. Use Maps instead.
At that point your code might make enough sense that we could see what to do next.
Was This Post Helpful? 1
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,904
  • Joined: 06-March 08

Re: java.lang.String.charAt(String.java:658)

Posted 15 November 2012 - 09:47 AM

Holly smoke !!!

A single method should be all visible on your monitor screen
You have a monitor that display 800 lines of code ? Which brand, I want to buy one.

You need an IQ of more than 100 to understand 4 or more levels of indentation you must be a very very bright guy.

Rewrite that stuff with methods that have at max 80 lines....

Now your problem is a that a do { should finish by a } while(condition);

I have (my IDE did) correctly indent your code and I put a comment where the while should be at the end of your main() method.


import java.text.*;
import java.util.*;

public class University_Apartment
{
	public static void main (String[]arguments)
	{
		String studentName, studentID, passportNumber;
		String userInputMain, userInput1,userInput2, userInput3, userChoiceA, userChoiceFull, userChoiceFullA, apartmentType, register;
		String inputView1;
		String currentDate, assignDate, currentHour;
		char optionMain, optionInput1, optionInput2, optionInput3, optionChoiceA, optionChoiceFull, optionChoiceFullA, choiceView1;
		int index, index1, index2, houseNumber, roomNumber, ID;

		final int apartTypeA = 2;
		final int apartTypeB = 2;
		final int roomA = 2;
		final int roomB = 3;
		boolean next = false;
		boolean next1 = false;

		String [] apartmentA = { "FloorA1", "FloorA2"};
		String [] apartmentB = { "FloorB1", "FloorB2"};


		int[] FloorA1 = new int[apartTypeA];
		int[] FloorA2 = new int[apartTypeA];

		int[] FloorB1 = new int[apartTypeB];
		int[] FloorB2 = new int[apartTypeB];


		int[] HouseA1 = new int[roomA];
		int[] HouseA2 = new int[roomA];
		int[] HouseB1 = new int[roomB];
		int[] HouseB2 = new int[roomB];

		Scanner keyboard = new Scanner (System.in);

		do {
			System.out.println("+++++++++++++++++++++++++++++++++");
			System.out.println("Fortes Fortuna Apartment");
			System.out.println("+++++++++++++++++++++++++++++++++");
			System.out.println("Main Menu");
			System.out.println("---------------------------------");
			System.out.println("I - to Apartment Info");
			System.out.println("R - to Register New Student");
			System.out.println("V - to View Occupancy");
			System.out.println("Q - to Quit the system");
			userInputMain = keyboard.nextLine();
			optionMain = userInputMain.charAt(0);

			switch(optionMain)
			{
			case 'i' : case 'I':

				System.out.println("    APARTMENT INFORMATION");
				System.out.println("---------------------------------");
				System.out.println("A - Info Apartment A");
				System.out.println("B - Info Apartment B");
				System.out.println("M - to return to Main Menu");
				System.out.print("Enter : ");
				userInput1 = keyboard.nextLine();
				optionInput1 = userInput1.charAt(0);

				if(optionInput1 == 'M' || optionInput1 == 'm') {
					System.out.println();
					System.out.println("Back to Main Menu.");
					System.out.println();
				}
				else if(optionInput1 == 'A' || optionInput1 == 'a') {
					System.out.println("+++++++++ Apartment Type A +++++++++++");			
					System.out.println("2 bedrooms");
					System.out.println("Equipped with kitchen and laundry facilities");
					System.out.println("Monthly rental = RM300.");
					System.out.println("  M    - Return to main menu");
				}
				else if (optionInput1 == 'B' || optionInput1 == 'b') {
					System.out.println("+++++++++ Apartment Type B +++++++++++");
					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("*Master bedroom attached with inside bathroom");
					System.out.println("**People who live in master bedroom will be paying 40% more = RM280");
				}


			case 'r': case 'R':

				System.out.println("    Register New Student");
				System.out.println("---------------------------------");
				System.out.println("Enter your name :");
				studentName = keyboard.nextLine();

				System.out.println("Enter your Student ID :");
				studentID = keyboard.nextLine();

				System.out.println("Enter your Passport Number :");
				passportNumber = keyboard.nextLine();

				System.out.println("Which apartment type you want? (A/B)/>/>/>/>");
				userInput2 = keyboard.nextLine();
				optionInput2 = userInput2.charAt(0);

				switch(optionInput2)
				{
				case 'A':
					apartmentA:
						for (index = 0; index <=apartmentA.length; index++) {
							if (index == 2) {
								System.out.println("Sorry, all houses are full.");
								System.out.println("Please look for another floor");
								System.out.println(" M - Back to Main Menu");
								System.out.println(" Q - Quit ");
								userChoiceA = keyboard.nextLine();
								optionChoiceA = userChoiceA.charAt(0);

								if (optionChoiceA == 'm' || optionChoiceA == 'M'){
									System.out.println();
									System.out.println("Main Menu.");
								}
								else if (optionChoiceA == 'q' || optionChoiceA == 'Q'){
									System.exit(0);
								}
								break;}

							else if (FloorA1[index] < 1){
								System.out.println("What floor do you want? (1/2)");
								userInput3 = keyboard.nextLine();
								optionInput3 = userInput3.charAt(0);

								switch(optionInput3)
								{
								case '1':
									apartmentType = "Apartment Type A";
									for (index1 = 0; index1 <=FloorA1.length; index1++) {
										if (index1 == 2) {
											System.out.println("Sorry, all houses are full.");
											System.out.println("Please look for another floor");
											System.out.println(" M - Back to Main Menu");
											System.out.println(" Q - Quit ");
											userChoiceA = keyboard.nextLine();
											optionChoiceA = userChoiceA.charAt(0);
											if (optionChoiceA == 'm' || optionChoiceA == 'M'){
												System.out.println();
												System.out.println("Main Menu.");
											}
											else if (optionChoiceA == 'q' || optionChoiceA == 'Q'){
												System.exit(0);
											}

											else if (FloorA1[index1] < 1){
												System.out.println("Please choose house");
												System.out.println("C - choose house number");
												System.out.println("R - pick a random house");
												System.out.print("Enter your choice = ");
												userChoiceA = keyboard.nextLine();
												optionChoiceA = userChoiceA.charAt(0);
												if (optionChoiceA == 'c' ||  optionChoiceA == 'C'){
													System.out.print("Enter house number you want (1/2)= ");
													houseNumber = keyboard.nextInt();

													if ((houseNumber >= 1) && (houseNumber <= 2)) {
														if(FloorA1[houseNumber-1] == 0 ) {
															FloorA1[houseNumber-1] += 1;
															System.out.println("Enter room number you want(1-2)= ");
															roomNumber = keyboard.nextInt();

															if ((roomNumber >= 1) && (roomNumber <= 2)) {
																if (HouseA1[roomNumber-1] == 0 ) {
																	HouseA1 [roomNumber-1] += 1;
																	next1 = true;

																	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("Thanks, your room is in room "+ roomNumber +", house number"+
																			houseNumber +", 1st floor on "+ apartmentType);
																	break;
																}

																else {
																	next1 = false;
																	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;
																}   
															}
															else {								
																System.out.println();
																System.out.println("Wrong Type, Back to Main Menu");
																next1 = false;
																break;
															}
														}

														else {								
															System.out.println();
															System.out.println("Wrong Type, Back to Main Menu"); 
															next = false;
															break;
														}
													}
												}
												else {
													next = false;
													System.out.println();
													System.out.println("Sorry, these rooms are already booked");
													System.out.println("Please look for another room");
													System.out.println(" M - Back to Main Menu");
													System.out.println(" Q - Quit ");
													userChoiceFull = keyboard.nextLine();
													optionChoiceFull = userChoiceFull.charAt(0);

													if (optionChoiceFull == 'm' || optionChoiceFull == 'M'){
														System.out.println();
														System.out.println("Main Menu.");
													}
													else if (optionChoiceFull == 'q' || optionChoiceFull == 'Q'){
														System.exit(0);
													}								
													break;
												}
											}

											else if (optionChoiceA == 'r' || optionChoiceA == 'R') {								
												for ( index1 = 0; index1 < 2 ; index1++ ) {
													if (FloorA1[index1] == 0 ) {											
														FloorA1[index1] += 1;
														houseNumber = index1;
														houseNumber += 1;
														next1 = true;
														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("Thanks, your room is in room "+ roomNumber +", house number"+
																houseNumber +", 1st floor on "+ apartmentType);
														break;
													}
												}
											}
											else {								
												System.out.println();
												System.out.println("Invalid choice");
												System.out.println("Back to Main Menu"); 
												System.out.println();
												next = false;
												break;
											}
										}
									}

									break;


								case '2':
									apartmentType = "Apartment Type A";
									for (index1 = 0; index1 <=FloorA2.length; index1++) {
										if (index1 == 2) {
											System.out.println("Sorry, all houses are full.");
											System.out.println("Please look for another floor");
											System.out.println(" M - Back to Main Menu");
											System.out.println(" Q - Quit ");
											userChoiceA = keyboard.nextLine();
											optionChoiceA = userChoiceA.charAt(0);
											if (optionChoiceA == 'm' || optionChoiceA == 'M'){
												System.out.println();
												System.out.println("Main Menu.");
											}
											else if (optionChoiceA == 'q' || optionChoiceA == 'Q'){
												System.exit(0);
											}

											else if (FloorA2[index1] < 1){
												System.out.println("Please choose house");
												System.out.println("C - choose house number");
												System.out.println("R - pick a random house");
												System.out.print("Enter your choice = ");
												userChoiceA = keyboard.nextLine();
												optionChoiceA = userChoiceA.charAt(0);
												if (optionChoiceA == 'c' ||  optionChoiceA == 'C'){
													System.out.print("Enter house number you want (1/2)= ");
													houseNumber = keyboard.nextInt();

													if ((houseNumber >= 1) && (houseNumber <= 2)) {
														if(FloorA2[houseNumber-1] == 0 ) {
															FloorA2[houseNumber-1] += 1;
															System.out.println("Enter room number you want(1/2)= ");
															roomNumber = keyboard.nextInt();

															if ((roomNumber >= 1) && (roomNumber <= 2)) {
																if (HouseA2[roomNumber-1] == 0 ) {
																	HouseA2 [roomNumber-1] += 1;
																	next1 = true;

																	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("Thanks, your room is in room "+ roomNumber +", house number"+
																			houseNumber +", 1st floor on "+ apartmentType);
																	break;
																}

																else {
																	next1 = false;
																	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;
																}   
															}
															else {								
																System.out.println();
																System.out.println("Wrong Type, Back to Main Menu"); 
																next = false;
																break;
															}
														}

														else {								
															System.out.println();
															System.out.println("Wrong Type, Back to Main Menu"); 
															next = false;
															break;
														}
													}
												}
												else {
													next = false;
													System.out.println();
													System.out.println("Sorry, these rooms are already booked");
													System.out.println("Please look for another room");
													System.out.println(" M - Back to Main Menu");
													System.out.println(" Q - Quit ");
													userChoiceFull = keyboard.nextLine();
													optionChoiceFull = userChoiceFull.charAt(0);

													if (optionChoiceFull == 'm' || optionChoiceFull == 'M'){
														System.out.println();
														System.out.println("Main Menu.");
													}
													else if (optionChoiceFull == 'q' || optionChoiceFull == 'Q'){
														System.exit(0);
													}								
													break;
												}
											}

											else if (optionChoiceA == 'r' || optionChoiceA == 'R') {								
												for ( index1 = 0; index1 < 2 ; index1++ ) {
													if (FloorA1[index1] == 0 ) {											
														FloorA1[index1] += 1;
														houseNumber = index1;
														houseNumber += 1;
														next1 = true;
														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("Thanks, your room is in room "+ roomNumber +", house number"+
																houseNumber +", 1st floor on "+ apartmentType);
														break;
													}
												}
											}
											else {								
												System.out.println();
												System.out.println("Invalid choice");
												System.out.println("Back to Main Menu"); 
												System.out.println();
												next = false;
												break;
											}
										}
									}

									break;                                        


								case 'B':
									apartmentB:
										for (index = 0; index <=apartmentB.length; index++) {
											if (index == 2) {
												System.out.println("Sorry, all houses are full.");
												System.out.println("Please look for another floor");
												System.out.println(" M - Back to Main Menu");
												System.out.println(" Q - Quit ");
												userChoiceA = keyboard.nextLine();
												optionChoiceA = userChoiceA.charAt(0);

												if (optionChoiceA == 'm' || optionChoiceA == 'M'){
													System.out.println();
													System.out.println("Main Menu.");
												}
												else if (optionChoiceA == 'q' || optionChoiceA == 'Q'){
													System.exit(0);
												}
												break;}

											else if (FloorB1[index] < 1){
												System.out.println("What floor do you want? (1/2)");
												userInput3 = keyboard.nextLine();
												optionInput3 = userInput3.charAt(0);

												switch(optionInput3)
												{
												case '1':
													apartmentType = "Apartment Type B";
													for (index2 = 0; index2 <=FloorB1.length; index2++) {
														if (index2 == 2) {
															System.out.println("Sorry, all houses are full.");
															System.out.println("Please look for another floor");
															System.out.println(" M - Back to Main Menu");
															System.out.println(" Q - Quit ");
															userChoiceA = keyboard.nextLine();
															optionChoiceA = userChoiceA.charAt(0);
															if (optionChoiceA == 'm' || optionChoiceA == 'M'){
																System.out.println();
																System.out.println("Main Menu.");
															}
															else if (optionChoiceA == 'q' || optionChoiceA == 'Q'){
																System.exit(0);
															}

															else if (FloorB1[index2] < 1){
																System.out.println("Please choose house");
																System.out.println("C - choose house number");
																System.out.println("R - pick a random house");
																System.out.print("Enter your choice = ");
																userChoiceA = keyboard.nextLine();
																optionChoiceA = userChoiceA.charAt(0);
																if (optionChoiceA == 'c' ||  optionChoiceA == 'C'){
																	System.out.print("Enter house number you want (1/2)= ");
																	houseNumber = keyboard.nextInt();

																	if ((houseNumber >= 1) && (houseNumber <= 2)) {
																		if(FloorB1[houseNumber-1] == 0 ) {
																			FloorB1[houseNumber-1] += 1;
																			System.out.println("Enter room number you want(1-2)= ");
																			roomNumber = keyboard.nextInt();

																			if ((roomNumber >= 1) && (roomNumber <= 2)) {
																				if (HouseB1[roomNumber-1] == 0 ) {
																					HouseB1 [roomNumber-1] += 1;
																					next1 = true;

																					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("Thanks, your room is in room "+ roomNumber +", house number"+
																							houseNumber +", 1st floor on "+ apartmentType);
																					break;
																				}

																				else {
																					next1 = false;
																					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;
																				}   
																			}
																			else {								
																				System.out.println();
																				System.out.println("Wrong Type, Back to Main Menu"); 
																				next = false;
																				break;
																			}
																		}

																		else {								
																			System.out.println();
																			System.out.println("Wrong Type, Back to Main Menu"); 
																			next = false;
																			break;
																		}
																	}
																}
																else {
																	next = false;
																	System.out.println();
																	System.out.println("Sorry, these rooms are already booked");
																	System.out.println("Please look for another room");
																	System.out.println(" M - Back to Main Menu");
																	System.out.println(" Q - Quit ");
																	userChoiceFull = keyboard.nextLine();
																	optionChoiceFull = userChoiceFull.charAt(0);

																	if (optionChoiceFull == 'm' || optionChoiceFull == 'M'){
																		System.out.println();
																		System.out.println("Main Menu.");
																	}
																	else if (optionChoiceFull == 'q' || optionChoiceFull == 'Q'){
																		System.exit(0);
																	}								
																	break;
																}
															}

															else if (optionChoiceA == 'r' || optionChoiceA == 'R') {								
																for ( index2 = 0; index2 < 2 ; index2++ ) {
																	if (FloorA1[index2] == 0 ) {											
																		FloorA1[index2] += 1;
																		houseNumber = index2;
																		houseNumber += 1;
																		next = true;
																		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("Thanks, your room is in room "+ roomNumber +", house number"+
																				houseNumber +", 1st floor on "+ apartmentType);
																		break;
																	}
																}
															}
															else {								
																System.out.println();
																System.out.println("Invalid choice");
																System.out.println("Back to Main Menu"); 
																System.out.println();
																next = false;
																break;
															}
														}
													}

													break;


												case '2':
													apartmentType = "Apartment Type B";
													for (index2 = 0; index2 <=FloorB2.length; index2++) {
														if (index2 == 2) {
															System.out.println("Sorry, all houses are full.");
															System.out.println("Please look for another floor");
															System.out.println(" M - Back to Main Menu");
															System.out.println(" Q - Quit ");
															userChoiceA = keyboard.nextLine();
															optionChoiceA = userChoiceA.charAt(0);
															if (optionChoiceA == 'm' || optionChoiceA == 'M'){
																System.out.println();
																System.out.println("Main Menu.");
															}
															else if (optionChoiceA == 'q' || optionChoiceA == 'Q'){
																System.exit(0);
															}

															else if (FloorB2[index2] < 1){
																System.out.println("Please choose house");
																System.out.println("C - choose house number");
																System.out.println("R - pick a random house");
																System.out.print("Enter your choice = ");
																userChoiceA = keyboard.nextLine();
																optionChoiceA = userChoiceA.charAt(0);
																if (optionChoiceA == 'c' ||  optionChoiceA == 'C'){
																	System.out.print("Enter house number you want (1/2)= ");
																	houseNumber = keyboard.nextInt();

																	if ((houseNumber >= 1) && (houseNumber <= 2)) {
																		if(FloorB2[houseNumber-1] == 0 ) {
																			FloorB2[houseNumber-1] += 1;
																			System.out.println("Enter room number you want(1/2)= ");
																			roomNumber = keyboard.nextInt();

																			if ((roomNumber >= 1) && (roomNumber <= 2)) {
																				if (HouseB2[roomNumber-1] == 0 ) {
																					HouseB2 [roomNumber-1] += 1;
																					next1 = true;

																					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("Thanks, your room is in room "+ roomNumber +", house number"+
																							houseNumber +", 1st floor on "+ apartmentType);
																					break;
																				}

																				else {
																					next1 = false;
																					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;
																				}   
																			}
																			else {								
																				System.out.println();
																				System.out.println("Wrong Type, Back to Main Menu"); 
																				next = false;
																				break;
																			}
																		}
																		else {								
																			System.out.println();
																			System.out.println("Wrong Type, Back to Main Menu"); 
																			next = false;
																			break;
																		}
																	}
																}
																else {
																	next = false;
																	System.out.println();
																	System.out.println("Sorry, these rooms are already booked");
																	System.out.println("Please look for another room");
																	System.out.println(" M - Back to Main Menu");
																	System.out.println(" Q - Quit ");
																	userChoiceFull = keyboard.nextLine();
																	optionChoiceFull = userChoiceFull.charAt(0);

																	if (optionChoiceFull == 'm' || optionChoiceFull == 'M'){
																		System.out.println();
																		System.out.println("Main Menu.");
																	}
																	else if (optionChoiceFull == 'q' || optionChoiceFull == 'Q'){
																		System.exit(0);
																	}								
																	break;
																}
															}

															else if (optionChoiceA == 'r' || optionChoiceA == 'R') {								
																for ( index2 = 0; index2 < 2 ; index2++ ) {
																	if (FloorA1[index2] == 0 ) {											
																		FloorA1[index2] += 1;
																		houseNumber = index2;
																		houseNumber += 1;
																		next1 = true;
																		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("Thanks, your room is in room "+ roomNumber +", house number"+
																				houseNumber +", 1st floor on "+ apartmentType);
																		break;
																	}
																}
															}
															else {								
																System.out.println();
																System.out.println("Invalid choice");
																System.out.println("Back to Main Menu"); 
																System.out.println();
																next = false;
																break;
															}
														}
													}

													break;




												case 'v' : case 'V':     

													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 : ");
													userInput1 = keyboard.nextLine();
													optionInput1 = userInput1.charAt(0);
													if(optionInput1 == 'M' || optionInput1 == 'm') {
														System.out.println();
														System.out.println("Back to Main Menu.");
														System.out.println();
													}
													else if(optionInput1 == 'A' || optionInput1 == 'a') {
														System.out.print("Please choose a floor number: (1-10)");
														inputView1 = keyboard.nextLine();
														choiceView1 = inputView1.charAt(0);

														switch (choiceView1){
														case '1' :
															ID = 1;
															System.out.println("*************************************************");
															System.out.println("*               Apartment Type A                *");
															System.out.println("*************************************************");
															System.out.print("*");
															for(index1 = 0; index1 < FloorA1.length; index1++){
																System.out.print("       " + FloorA1[index1]);
																if(index1 == 2){
																	System.out.print("       *");
																	System.out.println();
																	System.out.println("*************************************************");
																	System.out.print("*");
																}
															}
															System.out.print("       *");
															System.out.println();
															System.out.println("*************************************************");
															System.out.println("*                Apartment Type B               *");
															System.out.println("*************************************************");
															System.out.print("*");
															for(index2 = 1; index2 < (FloorB1.length + 1); index2++){
																System.out.print("       " + FloorB2[(index2-1)]);
																if(index2 % 5 == 0){
																	System.out.print("       *");
																	System.out.println();
																	System.out.println("*************************************************");
																	if(index2 / 5 == 0){
																		System.out.print("*");
																	}
																}
															}           
															System.out.println();
															break;
														}
														break;
													}


												case 'q' : case 'Q' :
													System.out.println("You quit the system");
													System.exit(0);
													break;

												default :
													System.out.println("Wrong type, back to Main Menu.");
													break;
												}       while( optionMain != 'q' || optionMain != 'Q');


											}
										}
								}
							}
						}
				}
			}
		} // <----  here shoul be a while
	}
}




Was This Post Helpful? 2
  • +
  • -

#5 Zakii  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 15-November 12

Re: java.lang.String.charAt(String.java:658)

Posted 15 November 2012 - 10:04 AM

View Postpbl, on 15 November 2012 - 09:47 AM, said:



Thank you very much..
I solved it :)

jon.kiparsky said:

Thanks


Thanks :)
Was This Post Helpful? 0
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,904
  • Joined: 06-March 08

Re: java.lang.String.charAt(String.java:658)

Posted 15 November 2012 - 10:07 AM

You have so many menus... I can't beleive you cannot write a char method that receives: the title, the questions, the possible answers as parameter and return the selected answer.
Was This Post Helpful? 0
  • +
  • -

#7 Zakii  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 15-November 12

Re: java.lang.String.charAt(String.java:658)

Posted 17 November 2012 - 10:30 AM

I got this error :

at java.lang.String.charAt(String.java:658)
at University_Apartment.main(University_Apartment.jav a:54)
Java Result: 1

when I choose the house number in my program..
anybody know what's wrong with the code?
Thank 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, 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 ");
                                
				houseNumber = keyboard.nextInt();
                                
                                switch(houseNumber) {
			
                                case '1' :
                               
				
                                    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)");
                                            roomNumber = keyboard.nextInt();
                        
                                            if (roomNumber == 1){
                                                if (HouseA1[roomNumber-1] == 0 ) {
                                                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();
                                            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 (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)");
                                            roomNumber = keyboard.nextInt();
                        
                                            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)");
                                            roomNumber = keyboard.nextInt();
                        
                                            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)");
                                            roomNumber = keyboard.nextInt();
                        
                                            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)");
                                            roomNumber = keyboard.nextInt();
                        
                                            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 ");
                                
				houseNumber = keyboard.nextInt();
                                
                                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");
                                            roomNumber = keyboard.nextInt();
                        
                                            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");
                                            roomNumber = keyboard.nextInt();
                        
                                            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");
                                            roomNumber = keyboard.nextInt();
                        
                                            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");
                                            roomNumber = keyboard.nextInt();
                        
                                            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");
                                            roomNumber = keyboard.nextInt();
                        
                                            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');
        }
}


Was This Post Helpful? 0
  • +
  • -

#8 Zakii  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 15-November 12

Re: java.lang.String.charAt(String.java:658)

Posted 17 November 2012 - 10:49 AM

View Postpbl, on 15 November 2012 - 10:07 AM, said:

You have so many menus... I can't beleive you cannot write a char method that receives: the title, the questions, the possible answers as parameter and return the selected answer.


hi buddy, can you help me again..

i don't know why my program got an error when i choose house number in my program..
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, 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 ");
                                
				houseNumber = keyboard.nextInt();
                                
                                switch(houseNumber) {
			
                                case '1' :
                               
				
                                    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)");
                                            roomNumber = keyboard.nextInt();
                        
                                            if (roomNumber == 1){
                                                if (HouseA1[roomNumber-1] == 0 ) {
                                                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();
                                            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 (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)");
                                            roomNumber = keyboard.nextInt();
                        
                                            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)");
                                            roomNumber = keyboard.nextInt();
                        
                                            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)");
                                            roomNumber = keyboard.nextInt();
                        
                                            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)");
                                            roomNumber = keyboard.nextInt();
                        
                                            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 ");
                                
				houseNumber = keyboard.nextInt();
                                
                                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");
                                            roomNumber = keyboard.nextInt();
                        
                                            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");
                                            roomNumber = keyboard.nextInt();
                        
                                            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");
                                            roomNumber = keyboard.nextInt();
                        
                                            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");
                                            roomNumber = keyboard.nextInt();
                        
                                            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");
                                            roomNumber = keyboard.nextInt();
                        
                                            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');
        }
}


Was This Post Helpful? 0
  • +
  • -

#9 DoinWork  Icon User is offline

  • D.I.C Head

Reputation: 15
  • View blog
  • Posts: 69
  • Joined: 26-October 11

Re: java.lang.String.charAt(String.java:658)

Posted 17 November 2012 - 11:36 AM

Following the options to choose that throws this(when registering new student, I switched the line to
userInputI = keyboard.nextLine();
houseNumber = Integer.parseInt(userInputI);



Then changed the switches to 1 instead of '1' and it worked fine.
Was This Post Helpful? 1
  • +
  • -

#10 no2pencil  Icon User is online

  • Admiral Fancy Pants
  • member icon

Reputation: 5388
  • View blog
  • Posts: 27,383
  • Joined: 10-May 07

Re: java.lang.String.charAt(String.java:658)

Posted 17 November 2012 - 11:43 AM

** Renamed title to be more descriptive **

** Topics merged **

Please be more mindful when posting topics. If you have any questions, feel free to shoot me a private message.
Was This Post Helpful? 1
  • +
  • -

#11 Zakii  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 15-November 12

Re: java.lang.String.charAt(String.java:658)

Posted 17 November 2012 - 07:35 PM

View PostDoinWork, on 17 November 2012 - 11:36 AM, said:

Following the options to choose that throws this(when registering new student, I switched the line to
userInputI = keyboard.nextLine();
houseNumber = Integer.parseInt(userInputI);



Then changed the switches to 1 instead of '1' and it worked fine.



thank you very much bro..
u save my life..
LOL :D/>/>
it works :)/>/>
Was This Post Helpful? 0
  • +
  • -

#12 Zakii  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 15-November 12

Re: java.lang.String.charAt(String.java:658)

Posted 17 November 2012 - 07:40 PM

View Postno2pencil, on 17 November 2012 - 11:43 AM, said:

** Renamed title to be more descriptive **

** Topics merged **

Please be more mindful when posting topics. If you have any questions, feel free to shoot me a private message.


sorry, but i already post this question in the new title post before i post here..
actually that question just to ask @pbl.
regards :)/>
hhe
Was This Post Helpful? 0
  • +
  • -

#13 Zakii  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 15-November 12

Re: java.lang.String.charAt(String.java:658)

Posted 17 November 2012 - 07:46 PM

View Postno2pencil, on 17 November 2012 - 11:43 AM, said:

** Renamed title to be more descriptive **

** Topics merged **

Please be more mindful when posting topics. If you have any questions, feel free to shoot me a private message.


opps sorry i just realized that i was really post it(in the new title) here, my bad..
human error.. sorry again :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1