104k views
5 votes
Does this Java Program look correct? First, let me paste the question:Five friends are going to the theater. They have purchased a row of five seats with an aisle on either end.James doesn't want to sit next to JillBetty and Herb are dating and want to sit next to each otherBob must sit on an aisleProvide a seating order that conforms to the above rules. An example of an invalid seating order is:James, Betty, Herb, Bob, JillThe above arrangement is invalid because: Bob is not sitting on an aisle.Specify the seating order as the names separated by commas (as in the above example). Please be sure to spell the names correctly, including capitalization.My Program:public class Seating{ public static void main (String [] args){ String James; String Jill; String Betty; String Herb; String Bob; system.output.println(Bob + "," + Jill + "," + Herb + "," + Betty + "," + James + "."; }}

User JPWilson
by
4.8k points

1 Answer

2 votes

Answer:

Your program is correct.

Step-by-step explanation:

You have this requeriments:

  • James doesn't want to sit next to Jill.
  • Betty and Herb are dating and want to sit next to each other.
  • Bob must sit on an aisle.
  • Aisle on either end.

Your answer:

public class Seating{

public static void main (String [] args)

{ String James;

String Jill;

String Betty;

String Herb;

String Bob;

system.output.println(Bob + "," + Jill + "," + Herb + "," + Betty + "," + James + "."; } //Bob is an aisle. James is not sit next to Jill. Betty and Herb are sit together.

}

User SaroVin
by
4.4k points