Write a program that allows the user to enter a list of up to 100 integers. Please check for boundary conditions, for example, the user has to enter more than 0 integers but not more then 100. The end of the list is indicated by the special value -1. The program then reads more integers (max. 100), and, for every value, tells whether or not the value appears in the first list. The program ends when the user enters -1 (for the second time). For example, for the input

How do I compare the second list with the first list...Also note that Im using StdIn.readInt(); and I have all the files to use it...I got them from "introduction to programming an indeseplinary approach" website.

March 10th, 2012, 11:42 AM

Norm

Re: I/O List.java

Quote:

How do I compare the second list with the first list..

How do you want to compare the arrays?
If element by element, use a loop with an if test to compare the elements from each array.
Otherwise explain what you mean by comparing the arrays.

March 10th, 2012, 12:57 PM

Janno

Re: I/O List.java

[QUOTE=Norm;60425]How do you want to compare the arrays?

The program has to tell you whether or not a value in the second list appears in the first list.

March 10th, 2012, 01:05 PM

Norm

Re: I/O List.java

That sounds like a search. Take an element from the second list and search the first list.