RoomLookup

RoomLookup - } System.out.println("Ready"); int...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
public class RoomLookup{ public static void main(String[ ] args){ final int MAXROOMS = 4; int roomNum [ ] = new int [MAXROOMS]; String resident[ ] = new String [MAXROOMS]; for(int i=0; i<MAXROOMS; i++){ roomNum[i]=IO.readInt( ); resident[i] = IO.readString( ); } for(int i=0; i<MAXROOMS; i++){ System.out.println(i+" " + roomNum[i]+ " " + resident[i]);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } System.out.println("Ready"); int i; String name = IO.readString( ); while(! name.equals("")){ for(i=0; i<MAXROOMS && ! resident[i].equals(name);i++){ } if (i == MAXROOMS){ System.out.println(name+ " not a resident"); } else { System.out.println(name + " resides in room " + roomNum[i]); } name = IO.readString( ); } } }...
View Full Document

This note was uploaded on 07/12/2009 for the course CS 111 taught by Professor Hari during the Fall '08 term at Rutgers.

Ask a homework question - tutors are online