Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
import java.io.FileNotFoundException;
import java.util.Scanner;
/*
* COPYRIGHT. HSBC HOLDINGS PLC 2014. ALL RIGHTS RESERVED.
*
* This software is only to be used for the purpose for which it has been
* provided. No part of it is to be reproduced, disassembled, transmitted,
* stored in a retrieval system nor translated in any human or computer
* language in any way or for any other purposes whatsoever without the prior
* written consent of HSBC Holdings plc.
*/
/**
* <p>
* <b> TODO : Insert description of the class's responsibility/role. </b>
* </p>
*/
public class PrintSeat {
public static void main(final String[] args) throws FileNotFoundException {
String seatNo[] = new String[100];
Scanner in = new Scanner(new File("seat.txt"));
for (int i = 0; in.hasNext(); i++) {
seatNo[i] = in.next();
}
int temp = 0;
int temp2 = 0;
int rowseat = 0;
int seatstart = 1;
// print format
System.out
.print(" *********************************************SCREEN****************************************************");
System.out.println();
System.out
.println(" | |");
for (char i = 'A'; i <= 'K'; i++) {
// System.out.println();
if ((((int) i) % 2) != 0) {
rowseat = 20;
} else {
rowseat = 20;
}
if (rowseat == 19) {
System.out.print(" ");
}
System.out.print(i + " |");
if (seatNo[temp].charAt(1) != i) {
for (int k = 1; k <= rowseat; k++) {
if (k < 10) {
System.out.print(" [0" + k + "]");
} else {
System.out.print(" [" + k + "]");
}
}
}
while ((seatNo[temp] != null) && (seatNo[temp].charAt(1) == i)) {
if (seatNo[temp].charAt(2) == '0') {
for (int k = seatstart; k < ((int) seatNo[temp].charAt(3) - 48); k++) {
System.out.print(" [0" + k + "]");
seatstart = k + 1;
}
seatstart++;
System.out.print(" [--]");
} else if (seatNo[temp].charAt(2) == '1') {
for (int k = seatstart; k < ((int) seatNo[temp].charAt(3) - 48 + 10); k++) {
if (k < 10) {
System.out.print(" [0" + k + "]");
} else {
System.out.print(" [" + k + "]");
}
seatstart = k + 1;
}
System.out.print(" [--]");
seatstart++;
} else if (seatNo[temp].charAt(2) == '2') {
for (int k = seatstart; k < ((int) seatNo[temp].charAt(3) - 48 + 20); k++) {
if (k < 10) {
System.out.print(" [0" + k + "]");
} else {
System.out.print(" [" + k + "]");
}
seatstart = k + 1;
}
System.out.print(" [--]");
seatstart++;
}
if (seatNo[temp + 1] != null) {
temp2 = seatstart;
if (seatNo[temp + 1].charAt(1) != i) {
for (int k = 1; k <= rowseat - seatstart + 1; k++) {
if (temp2 < 10) {
System.out.print(" [0" + temp2 + "]");
} else {
System.out.print(" [" + temp2 + "]");
}
temp2++;
}
}
} else {
temp2 = seatstart;
for (int k = 1; k <= rowseat - seatstart + 1; k++) {
if (temp2 < 10) {
System.out.print(" [0" + temp2 + "]");
} else {
System.out.print(" [" + temp2 + "]");
}
temp2++;
}
}
temp++;
}
seatstart = 1;
System.out.println(" | " + i);
System.out
.println(" | |");
}
System.out
.println(" -------------------------------------------------------------------------------------------------------");
/**
* System.out.println(); System.out.print("\");
*
* for (int i = 1; i <= 9; i++) {
*
* System.out.print(" " + i); } for (int i = 10; i <= 20; i++) {
*
* System.out.print(" " + i); }
**/
}
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team