Welcome to the Java Programming Forums


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


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


>> REGISTER NOW TO START POSTING


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

Results 1 to 4 of 4

Thread: Need HELP! Illegal start of expression & while expected..

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

    Default Need HELP! Illegal start of expression & while expected..

    I have no idea what's the mistake,
    Its say illegal start of expression & 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');
     
     
       }
                            }
                                        }
                                    }
                            }
                        }
            }
            }
            }
    }


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Need HELP! Illegal start of expression & while expected..

    Wow, you probably wouldn't know. That is a hell of a lot of code. First of all, you need to tell us specifically where in the code the errors are. Second, I would HIGHLY suggest you split up as much of that into individual methods as you can. Individual methods for long processes make your code easier to read and easier to manage.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. #3
    Member suyog53's Avatar
    Join Date
    Sep 2012
    Location
    Mumbai
    Posts
    37
    My Mood
    Daring
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: I can't figure out why this isn't working!

    Hi...............'
    @Zaki'
    --------------------------------------------------------------------------------------------
    You have done 2 mistakes..................'
    First, you did not initialize the variable roomNumber on line 269'
    Just initialize roomNumber = 0 on line 22'
    Second, you used do loop which is not needed on line 49'
    remove do from that line'
    Hope my post helps you.................'
    --------------------------------------------------------------------------------------------
    Last edited by suyog53; November 16th, 2012 at 02:06 AM. Reason: No need to move post

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Need HELP! Illegal start of expression & while expected..

    Near the top of the code you started a do while loop.

    do {

    is there near the top, but when the block finally ends with

    }

    there is no while.

    } while(someCondition);

Similar Threads

  1. PROBLEM: ILLEGAL START OF EXPRESSION
    By zerfgog in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 29th, 2012, 06:24 AM
  2. " Illegal start of expression" Error.
    By SanoSuke in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 21st, 2011, 08:08 PM
  3. illegal start of expression error!!!!
    By aks.1393 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 14th, 2011, 08:47 AM
  4. Illegal start
    By hing09 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: March 25th, 2010, 05:23 PM
  5. Illegal Start of Expression Error. Any help is appreciated.
    By SKhoujinian91 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 8th, 2009, 12:57 AM