Checking For Duplicates

Hello, my head hurts from trying to figure this out.

For an assignment I have designed a program that inputs school ID, grades for 2 homeworks, and the sum of the 2 homework grades, and then outputs all the data on one line and ends.

That part was simple, now I have to do a variation where the program loops, and if the user enters a school ID that is the same as one entered before, it is supposed to output an error. <-- This is what is melting my brain.

I tried doing:

if (usid == usid) {cerr...} and that didn't work.

I also have to have the program check that the grades entered are between 0-100, and I did that easily.

Note that we have only covered up to random number generating. I searched for similar problems and only found problems that had to do with arrays, which we haven't covered and I doubt we would have to use for this assignment.

Any help is greatly appreciated.
Are you writing to a file? If so, just read from the file and check to make sure that string doesn't appear. If you're storing in some container, just check each spot in the container for a matching string.
An array would be the way to go (or some other container). My feeling is that your question is too "beginner" to get a straight answer on the internet.

So why would I give it to you? :)

Make another variable and have it store the previous entry. Your loop checks the entry against the previous one. Not a very robust program, but you're going to need things you haven't learned yet to do it any better.
Topic archived. No new replies allowed.