java - how to display an array that would depends on what the user wants? -


this 1 method .

public static void main(string[] ropher)throws ioexception{     bufferedreader br = new bufferedreader (new inputstreamreader (system.in));      string[] accommodation = {"", "standard room", "double room", "matrimonial room", "triple room"}; // accommodation     int switchone, switchtwo;     int option;//options      /*-----------------------------------------------------------------      * costumer's information      -----------------------------------------------------------------*/     do{//start of first loop - customer's info     system.out.print("\nenter number of records : ");     int records = integer.parseint(br.readline());     string [][] fullname = new string [records][100];     int [] night = new int[100];     int [] guest = new int[100];     int[] confirm = new int [100];     (int x = 0; x < records; x++){// start records      system.out.print("\nconfimation number: ");     confirm[x] = integer.parseint(br.readline());     system.out.print("\nfirst name: ");     fullname[x][0] = br.readline();     system.out.print("last name: ");     fullname[x][1] = br.readline();     system.out.print("guest: ");     guest[x] = integer.parseint(br.readline());     system.out.print("night: ");     night[x] = integer.parseint(br.readline());     system.out.println();      do{// start of second - main menu          system.out.print("\n                             ||main menu||\n\n");         system.out.print("|=====================================================================|");         system.out.print("\n  ************************     bed types     ************************\n");         system.out.print("|=====================================================================|\n\n");         system.out.print("1. standard..............................................p500.00\n");         system.out.print("2. double................................................p800.00\n");         system.out.print("3. matrimonial...........................................p1,240.00\n");         system.out.print("4. triple................................................p1,500.00 \n");         system.out.print("5. exit\n");         system.out.println("\n   (wifi, air conditioned room, led tv, free breakfast)");         system.out.println("\t *except standard rooms , double rooms");                 system.out.print("\n\nplease select room type: ");         switchone = integer.parseint(br.readline());           //start of switch switchone - first switch       if ((x + 1 - records) == 0){      system.out.print("\n\nlist of customers:");      (x = 0; x < records; x++){          system.out.print("\n|---------------------------------------------------------------------|\n");         system.out.print("\n\nconfirmation number:      |--------------->  " +   confirm[x]);         system.out.print("\nguest name:                 |--------------->  " + fullname [x][0] + " " + fullname [x][1]);         system.out.print("\nnumber of guest:            |--------------->  " + guest [x]);         system.out.print("\nnumber of nights:           |--------------->  " + night[x]); 

this option, don't know value put in accommodation.

system.out.println("\naccommodations: |---------------> " + accommodation[switchone]);

            }      }else{             continue;         }      }// end records       }while (first);//end of first loop - customer's info   }//io }//body 

my program hotel information , billing system.

if there's 2 customer wants check-in , pick different rooms, , when checked customer's list output of rooms same.

and know problem is

    system.out.println("\naccommodations:               |--------------->  " + accommodation[switchone]); 

what fixed ?

help me please.

you using switchone know selected accomadation. if records 2 or more last record change value of switchone.

so when printing details, switchone same.

to avoid create new array selectedaccomadation[] , there. this

int[] confirm = new int [100]; string[] selectedaccomadation = new string[100]; ... system.out.print("\n\nplease select room type: "); selectedaccomadation[x] = br.readline(); 

and in loop this

system.out.println("\naccommodations: |---------------> " + selectedaccomadation[x]); 

please notify me if i'm wrong.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -