Welcome to Minetown!
To join our community, please login or register!
Internet Explorer
Internet Explorer is not supported. Please upgrade to a more modern browser.

[Enjin Archive] This weeks C++ homework!
Started by Unknown User

I'm assuming by make database he's talking about storing the info or some such work.

As far as making sure that people are only included once you just need to do a simple for+if statement to check that the names in all of the other slots are not the same as the name being added. you have to use .equals() for this instead of == or it won't work though.
Got the extra credit part working

void createDatabase()

{

char names;

double grades;

int i = 0;

cout << endl;

cout << "Enter DONE 0 when finished" << endl;

while(i < MAX_NUM_STUDENTS)

{

cout << "Enter student " << (i+1) <<"'s name and grade: ";

cin >> names;

cin >> grades;

bool unique = true;

int j = i-1;

while(j > -1)

{

if(strcmp(names, names) == 0)

{

unique = false;

break;

}

j--;

}

if(!unique)

{

cout << "Please enter a unique name." << endl;

}

else if(grades < 0 || grades > 100)

{

cout << "You entered an invalid grade. Please try again." << endl;

}

else if(strcmp(names, "DONE") == 0 || strcmp(names, "done") == 0 || strcmp(names, "Done") == 0)

{

break;

}

else

{

i++;

}

}

writeDatabase(names,grades, i);

}
Wow, I didn't know so many people programmed (let alone in C++) here. I've been doing C++ for roughly two and a half years now (same as HTML, CSS, PHP and JavaScript).
During class I demonstrated an example that appeared not to work. It was similar to the following:

int myArray = {10,20,30,40,50};

myArray++;

cout << myArray;

This resulted in the value 10 being printed instead of the expected value of 20. Why? We discussed the reason in class.

Btw this is my 100th post!! yayyy
YAY for A's but no yay for not working :/
I'm sorry but she's relying on a trick that i don't know. Basic things are that the index was not changed that the adresses that the array handles are of larger sets of bytes not just single item address changing.