Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication35;
- import java.util.Scanner;
- import java.util.Arrays;
- public class JavaApplication35 {
- public static void main(String[] args) {
- int[][]a=new int[2][5];
- int b=0, d=0,e=0;
- Scanner q=new Scanner(System.in);
- for(int x=0;x<2;x++)
- {
- for(int y=0;y<5;y++)
- {
- a[x][y]=0;
- }
- }
- System.out.println("please type 1-5 for business and 6-10 for economy");
- while(e<10)
- {
- int z=q.nextInt();
- if(z>=1&&z<=5)
- {
- b=0;
- d=z-1;
- }
- else if(z>=6&&z<=10)
- {
- b=1;
- d=z-6;
- }
- if(a[b][d]==0)
- {
- System.out.println("Seat is free");
- a[b][d]=1;
- e=e+a[b][d];
- }
- else if(a[b][d]==1)
- {
- System.out.println("Seat is taken");
- System.out.println(Arrays.deepToString(a));
- }
- }
- if(e==10)
- {
- System.out.println("All seats are reserved, the next plane leaves in 3 hours");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement