Please look at the images for exact instructions and sample output. Code should
ID: 3685946 • Letter: P
Question
Please look at the images for exact instructions and sample output. Code should be in Java. Do not use different classes. Need asap.
Your help will be very appreciated
Explanation / Answer
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; class Test{ public static void main(String[] args) throws IOException { String[][] seat = {{"10","10","10","10","10","10","10","10","10","10"}, {"10","10","10","10","10","10","10","10","10","10"}, {"10","10","10","10","10","10","10","10","10","10"}, {"10","10","20","20","20","20","20","20","10","10"}, {"10","10","20","20","20","20","20","20","10","10"}, {"10","10","20","20","20","20","20","20","10","10"}, {"20","20","30","30","40","40","30","30","20","20"}, {"20","30","30","40","50","50","40","30","30","20"}, {"30","40","50","50","50","50","50","50","40","30"}}; print(seat); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter 1 to choose by seat or 2 to choose by price"); while(true) { int ch = Integer.parseInt(br.readLine()); if (ch == 1) { do { System.out.println("Enter row:"); int r = Integer.parseInt(br.readLine()); while (!(r > 0 && r < 10)) { System.out.println("Invalid..try again"); r = Integer.parseInt(br.readLine()); } System.out.println("Enter seat:"); String col = br.readLine().trim().toUpperCase(); while (!(col.equals("A") || col.equals("B") || col.equals("C") || col.equals("D") || col.equals("E") || col.equals("F") || col.equals("G") || col.equals("H") || col.equals("I") || col.equals("J"))) { System.out.println("Invalid..try again"); col = br.readLine(); } String s = seat[9-r][getColumn(col)]; if(s.equals("XX")){ System.out.println("That seat is taken, please try again"); System.out.println("Enter 1 to choose by seat or 2 to choose by price"); continue; }else { seat[9-r][getColumn(col)] = "XX"; System.out.println("Your seat is booked!!"); print(seat); System.out.println("Enter 1 to choose by seat or 2 to choose by price"); break; } }while (true); } else if (ch == 2) { do { System.out.println("Enter a price(10,20,30,40,50):"); String price = br.readLine().trim(); while (!(price.equals("10") || price.equals("20") || price.equals("30") || price.equals("40") || price.equals("50"))) { System.out.println("That is not a valid price, please enter(10,20,30,40,50):"); price = br.readLine(); } for(int i=0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.