Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. package javaapplication35;
  2. import java.util.Scanner;
  3. import java.util.Arrays;
  4. public class JavaApplication35 {
  5.  
  6.    
  7.     public static void main(String[] args) {
  8.         int[][]a=new int[2][5];
  9.         int b=0, d=0,e=0;
  10.         Scanner q=new Scanner(System.in);
  11.  
  12.         for(int x=0;x<2;x++)
  13.         {
  14.             for(int y=0;y<5;y++)
  15.             {
  16.                 a[x][y]=0;
  17.             }
  18.         }
  19.        
  20.         System.out.println("please type 1-5 for business and 6-10 for economy");
  21.  
  22.         while(e<10)
  23.         {
  24.             int z=q.nextInt();
  25.             if(z>=1&&z<=5)
  26.             {
  27.                 b=0;
  28.                 d=z-1;
  29.             }
  30.             else if(z>=6&&z<=10)
  31.             {
  32.                 b=1;
  33.                 d=z-6;
  34.             }
  35.  
  36.  
  37.             if(a[b][d]==0)
  38.             {
  39.                 System.out.println("Seat is free");
  40.                 a[b][d]=1;
  41.                 e=e+a[b][d];
  42.             }
  43.             else if(a[b][d]==1)
  44.             {
  45.                 System.out.println("Seat is taken");
  46.                 System.out.println(Arrays.deepToString(a));
  47.             }
  48.         }
  49.        
  50.         if(e==10)
  51.         {
  52.             System.out.println("All seats are reserved, the next plane leaves in 3 hours");
  53.         }
  54.     }
  55.    
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement