C++ Help Please

Started by
2 comments, last by janta 16 years, 6 months ago
Heya. I'm pretty much new to the gamedev.net forums, but I've read a few things on here, and I thought I could get some help on an assignment I have in my C++ class at school. I have to create a program with something similar to the following prompt: Create a program that has a Student struct with 3 components: last name, ID number, and test grade. Create a Student type array with 5 elements for 5 students. Do not allow the user to have 2 of the same ID #'s. I thought at first that I had it all figured out, and then I ended up spending well over 6 hours trying to make it right. I did great on the inputting student information. What's stumping me is the comparing of ID numbers to see if there are any duplicates. I don't know how to do it. Here's what I've come up with in a separate program I'm doing to try and figure it out: // examination_solution.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<conio.h> #include<iostream> using namespace std; int main() { const int MAX = 5; int idNumbers[MAX]; int x; int i; int isIdentical = 1; for(x = 0; x < MAX; ++x) { cout<<"Enter user #"<<x + 1<<"'s ID Number: "; cin>>idNumbers[x]; } for(x = 0; x < MAX; x++) { for(i = 1; i < MAX; i++) { while(isIdentical == 1) { if(idNumbers[x] == idNumbers) { cout<<"User #"<<x + 1<<"s ID Number = User #"<<i + 1<<"'s ID Number."<<endl; cout<<"Enter user #"<<i + 1<<"'s number again "; cin>>idNumbers; isIdentical = 1; } else isIdentical = 0; } } } for(x = 0; x < MAX; ++x) { cout<<idNumbers[x]<<endl; } getch(); } Excuse the bit of disorderliness. If anybody could help, that would be great. :)
"I regret I wasn't born with opposable toes." - Calvin
Advertisement
1. Putting your code in [source] tags will preserve the code formatting, in most cases (you can edit your post using the 'edit' button in the upper right).

2. This would probably be more at home in the For Beginners forum (perhaps a mod will move it for you).

3. Strictly speaking, we're not supposed to help with homework problems here. We might be able to give you some hints or point you in the right direction though (which will be easier to do once your posted code is formatted correctly).
All right. I'm sorry about this. Maybe I could just leave this be then... I actually got pointed in the right direction from other sources, so I no longer need assistance. Sorry for my newbiness. :p
"I regret I wasn't born with opposable toes." - Calvin
4. Use a f***ing meaningful post title damn it.

This topic is closed to new replies.

Advertisement