error in java code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • webprogramer
    New Member
    • Nov 2007
    • 1

    #1

    error in java code

    Use an array to represent the seating chart of the plane. Initialize all the elements of the array to 0 to indicate that all seats are empty. As each seat is assigned, set the corresponding elements of the array to 1 to indicate that the seat is no longer available.


    import java.util.Array s;
    import java.util.Rando m;
    import java.lang.refle ct.Array;

    public class AirlineBooking1
    {
    // public AirlineBooking(
    //)
    final int SEATCAPACITY = 10;
    int smoke=1;
    int nonsmoke=2;
    int [] seatonezero;
    int m;

    AirlineBooking1 user = new AirlineBooking1 ();
    seat = new int[SEATCAPACITY];
    String[] seatonezero= { "0","0","0","0" ,"0","0","0","0 ","0","0" };

    System.out.prin tln("Seats options: 1)SMOKE 2)NON-SMOKE. Enter your choice: ");
    m = Keyboard.readIn t();
    System.out.prin tln m;

    for (int i = 0; i < 5; i++){
    seat[i] = 0;
    }
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by webprogramer
    Use an array to represent the seating chart of the plane. Initialize all the elements of the array to 0 to indicate that all seats are empty. As each seat is assigned, set the corresponding elements of the array to 1 to indicate that the seat is no longer available.


    import java.util.Array s;
    import java.util.Rando m;
    import java.lang.refle ct.Array;

    public class AirlineBooking1
    {
    // public AirlineBooking(
    //)
    final int SEATCAPACITY = 10;
    int smoke=1;
    int nonsmoke=2;
    int [] seatonezero;
    int m;

    AirlineBooking1 user = new AirlineBooking1 ();
    seat = new int[SEATCAPACITY];
    String[] seatonezero= { "0","0","0","0" ,"0","0","0","0 ","0","0" };

    System.out.prin tln("Seats options: 1)SMOKE 2)NON-SMOKE. Enter your choice: ");
    m = Keyboard.readIn t();
    System.out.prin tln m;

    for (int i = 0; i < 5; i++){
    seat[i] = 0;
    }
    1.) Use code tags when posting code
    2.) You have not told us what your exact problem is?
    3.) Why did you import java.lang.refle ct.Array?
    4.) You problem description did not say anything about smoking. What are all those smoke things in your code?
    5.) Did you try your code on the compiler?

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by webprogramer
      public class AirlineBooking1
      {
      AirlineBooking1 user = new AirlineBooking1 ();
      }
      Your code is a total mess and the stuff you're attempting to do (see above) makes
      your program go *kaboom* during runtime (if it ever compiles before that is).
      Please study and try to understand what you're attempting to do before you
      start hacking.

      kind regards,

      Jos

      Comment

      Working...