javascript - Airline seating using boolean -


i seem having quite difficult time midterm project. suppose ask if first class or coach seating, deduct whichever whichever , offer choice book seat.

i added section dialog options in first class seating , giving me parse error @ "dialogresult =" can't sort out why. in addition, when did work, loop start, deduct seat count, , not accept user input book again.

i think need set of eyes on this, confused myself here.

import javax.swing.*; import java.util.*;  class midterm2 {  public static void main(string[] args) {   boolean coachseats[] = new boolean[10];   boolean firstseats[] = new boolean [5];   int seatsfull = 0,firstseatcount,coachseatcount;     for(int i=0;i<10;i++){      firstseats[i] = false;      coachseats[i] = false;       do{         firstseatcount = 4;         coachseatcount = 9;         if(firstseats[i] == false) firstseatcount++;         if(coachseats[i] == false) coachseatcount++;           int seatclass = integer.parseint((string) joptionpane.showinputdialog(null,             "\n" + firstseatcount + " seats avaliable in first class "+             "\n" + coachseatcount + " seats avaliable in coach." +            "\npress 1 reserve seat in first class" +            "\npress 2 reserve seat in coach:"));          if (seatclass == 1){             if(firstseats[i] == false)               firstseats[i] = true;            firstseatcount = 1;{            dialogresult = joptionpane.yes_no_option;             joptionpane.showconfirmdialog(null, "\nboarding pass details -->" +                                          "\nseat number :" + (i+1) +                                          "\nfirst class" +                                          "\nwould reserve seat", joptionpane.yes_no_option);             if (dialogresult == joptionpane.yes_option);             if(dialogresult == joptionpane.no_option)                break;                             }                                                                  if(firstseatcount == 0){            joptionpane.showinputdialog ("\nno seats availabe in class," +                           "would travel in class(y/n):");                                     }                             } 

you have curly brace floating out on following line needs removed:

firstseatcount = 1;{ 

change to:

firstseatcount = 1; 

and should resolve parsing issue. haven't tried compiling code see if other issues exist should solve specific problem.

also, on formatting note, favor , please don't format braces in manner in doing it. although subjective, me there 2 practices:

if(boolean comparison){     code... } 

or personal favorite:

if(boolean comparison) {     code... } 

i may flamed or voted down some unorthodox style, really, doing other these 2 hurts readability, , tutors in programming, it's big pain in ass read code doesn't follow 1 of these 2 conventions. /endrant


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -