Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int ticket = Integer.parseInt(scanner.nextLine());
- for (int i = 0; i < ticket; i++){
- String combination = scanner.nextLine();
- int getFirst = (int)combination.charAt(0);
- if (combination.length() > 4){
- System.out.print("Seat decoded: ");
- System.out.print(combination.charAt(0));
- int num = (int)combination.charAt(1);
- System.out.print(num);
- System.out.println();
- }else if (getFirst > 64 && getFirst < 91){
- System.out.print("Seat decoded: ");
- System.out.println(combination.substring(0, 3));
- } else {
- System.out.print("Seat decoded: ");
- for (int j = combination.length() -1; j >= 0; j--){
- if (j == 3){
- System.out.print(combination.charAt(j));
- } else if (j == 1){
- System.out.print(combination.charAt(j));
- System.out.print(combination.charAt(j+1));
- }
- }
- System.out.println();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement