Minetown

There is currently 1 player online.

Connect now using the IP MT.GG

Internet Explorer

Internet Explorer is not supported. Please upgrade to a more modern browser.

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

[E] Cryston

[E] Cryston

Enjin Archive
Joined
23 Sep 2010
Last Seen
28 May 2021
Topics
28
Posts
564
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.
[E] Cryston · over 15 years ago
Unknown User

Unknown User
The content on this profile belongs to different accounts

Enjin Archive
Joined
30 Apr 2024
Last Seen
02 May 2024
Topics
1634
Posts
16066
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);

}
Unknown User · over 15 years ago
[E] JackM100

[E] JackM100

Enjin Archive
Joined
30 Apr 2011
Last Seen
30 May 2011
Topics
0
Posts
4
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).
[E] JackM100 · over 15 years ago
Unknown User

Unknown User
The content on this profile belongs to different accounts

Enjin Archive
Joined
30 Apr 2024
Last Seen
02 May 2024
Topics
1634
Posts
16066
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
Unknown User · over 15 years ago
[E] Gear

[E] Gear

Enjin Archive
Joined
23 Sep 2010
Last Seen
30 Sep 2021
Topics
110
Posts
1431
YAY for A's but no yay for not working :/
[E] Gear · over 15 years ago
[E] Cryston

[E] Cryston

Enjin Archive
Joined
23 Sep 2010
Last Seen
28 May 2021
Topics
28
Posts
564
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.
[E] Cryston · over 15 years ago