Results 1 to 3 of 3

Thread: System.out.println NEW LINE

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Posts
    159

    System.out.println NEW LINE

    Hey can anyone help


    I'm trying to print out the following using the code below:


    The following bedrooms are occupied:
    Room number 6 is occupied by evans, with payee private
    Room number 7 is occupied by jones, with payee private
    Room number 16 is occupied by smith, with payee uog hei

    End of bedroom report


    but ever time i compile it comes up all in one line. but if i use \n it gives me an error "Invalid escape character"

    any ideas?

    thanks

    Code:
    public void bedroomReport()
      {
        String  customerName = "";
        String  payeeName = "";
        int roomNumber = 0;
        boolean occupied;
        int counter = 1;
      
        while (counter <= MAX_BEDROOMS)
        {
          if (bedrooms[counter].isOccupied())
          {
            System.out.print("The following bedrooms are occupied:");
            System.out.print("Room number " + bedrooms[counter].getRoomNumber() + " is occupied by " + bedrooms[counter].getCustomerName() + " , with payee " + bedrooms[counter].getPayeeName());
          }
          counter++;
        }//end of while

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    You are using print(), not println().
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Posts
    159
    lol opps hehe thnks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width