I am on my last assignment and i have no idea how to do or start this one. This class has gotten to where i understand nothing when i watch the lectures. I have invested so much time trying to learn this stuff and i do not get structs. This assignment has me speechless, i am so lost. I have attached my assignment and the code output. ANY help would help me tremendously....

A structure is nothing more than a collection of items about a common topic. For example: If you want to know about students then you could write a student struct

struct student
{
    char name[40]; // student's name
    int ags;  // student's age
    char address[80]; 
    char city[40];
    char state[3];
    char zipcode[10];
};

That's all structures are -- they are a collection of attributes about something. Structures can contain other structures as well. For example

struct programming101
{
    struct student[100]; // 100 students for this course
    // other attributes may go here
};

I roughly get the idea of structs, that is not the problem. I looked at this assignment and it looks like chinese to me. I have not fully understood the last two topics we covered in class and this assignment is a combination of all of it. I am completely lost and have no idea at all how to even get started. This is my last assignment, thank god. But i am lost and dont know what to do...any input would help me out tremendously...

Write the program just a little bit at a time so that you don't get overwhelmed by the length of the assignment.

First, create a structure with the required members. The assignment doesn't say anything about their data types but I'd assume they are character arrays.

When you get that done and it compiles without error then post what you have done and move on to the next step.

This is what i have for the skeleton that i had help on. There are so many things that the assignment is asking for that i do not get. This is just a rough start but i have to use 5 functions with certain parameters??? Can anyone offer some more assistance...

//Assignment 9: Data Structures
//Curtis Davenport

#include <iostream>
using namespace std;

struct StudentName 

{
	char *first;
	char *last;
};

struct StudentData 

{
	StudentName name;
	// studentname contains first and last name

	char *nid;
	int score;

	void GetFirstName(char *fn) 
	{

	}

	void GetLastName(char *ln) 
	{

	}

	void GetNID(char *_nid) 
	{

	}

	void GetScore(int *_score) 
	{
		_score = &score;
	}

};

void DisplayStudent(StudentData student) 
{

}

int main() {
	cin.get();
	return 0;
}

The structure should contain character arrays, not pointers. It also needs more fields as required in the instructions you were given.

struct StudentName 

{
	char first[31];
	char last[31];
};
  • All work must be your own. You may discuss the material with other students but each student should do his/her own work.

That means we are not allowed to write the program for you. What you submit must be your work, not ours.

lines 23, 28 and 33: the Get functions should not have parameters. They should return const char*. For example

const char* GetFirstName() 
{

}

I wrote a similiar program in college about baseball players and their stats. You are looking to broadly at the assignment and getting frustrated. Focus on just 1 function. All the functions are very similiar and once you get one, the others will fall into place. I know you want the code and just be done, and I know I sound corny and woulda laughed at myself back then, but it really is better to hold off the frustration and just think about it.

P.S. learn to love google, this is a common program ;)

I have spent two hours staring at the screen. I keep reading through the instructions and thinking about it but does not matter. I just do not have the knowledge to even know where to start with the functions and the other stuff. I literally have no understanding of how to do this....Im not asking for anyone to complete the entire assignment i just need a bigger nudge in the right direction...Im freaking out because this is due in 4 days and this is all i have...plus a thousand other things to do in my other four classes....

//Assignment 9: Data Structures
//Curtis Davenport

#include <iostream>
using namespace std;

struct StudentName 

{
	char first[30];
	char last[30];

};

struct StudentData 

{
	StudentName name;
	// studentname contains first and last name

	char *nid;
	int score;

	void GetFirstName(char *fn) 
	{

	}

	void GetLastName(char *ln) 
	{

	}

	void GetNID(char *_nid) 
	{

	}

	void GetScore(int *_score) 
	{
		_score = &score;
	}

};

void DisplayStudent(StudentData student) 
{

}

int main() 

{
	cin.get();
	return 0;
}

Like Ancient Dragon already stated ..

Write the program just a little bit at a time so that you don't get overwhelmed by the length of the assignment.

So, try divide and conquer the problem.
It doesn't even have to be solid code but instead you can try and figure it out in pseudo-code first and post it here.

The first name must be validated to only accept lowercase and uppercase letters (limited to 30 characters).

That means you need to make room for 30 characters plus null terminator, or total of 31. char first[31];

The NID must be validated to only accept lowercase letters and numbers (limited to 30 characters).

Just like name, the NID (whatever that is) need to be 31 characters char NID[31]; There is no need for a pointer as you have it.

The four functions you have started are incorrect. Look at the return value in the instructions then in the code you hav eposted. They are not the same and you need to correct that.

Now to fill out those four get functions. A get function mearly returns a value from the structure of class. For example, the first one GetFirstName(char *fn) should copy the first name into the parameter and return either true if it was ok, or valse if there is no first name in the structure. Here's an example:

bool GetFirstName(char *fn)
{
    if( name.first[0] != 0 )
    {
        // first name is valid, so copy and return
        strcpy(fn, name.first);
        return true;
    }
    return false;
}

I am workin on the same problem but I am having a lot of problems too. This is what I have so far. Everytime I try to run it, it will let me enter the first and last name, but then script runs completely through without asking for the nid or the score. God only knows how I will get this assignment done by midnight. Please help

#include <iostream>

using namespace std;

struct NameType
{
    char first[30];
    char last[30];
};

struct StudentData
{
     NameType name;
     bool nid;
     float score;
};

StudentData ReadEntry();

void main()
{
    StudentData students[100];
    int i;
    int nStudents;

    do
    {
        cout << "Enter the number of students in the database [1-100]: ";
        cin  >> nStudents;
        if ((nStudents < 1) || (nStudents > 100))
        {
            cout << "Incorrect value. Try again... \n";
        }
    } while ((nStudents < 1) || (nStudents > 100));

    for (i = 0; i < nStudents; i++)
    {
        students[i] = ReadEntry();
    }

	cout << "\nEnter the curve score(0-100):";

}

StudentData ReadEntry()
{
    StudentData entry;

	int i=0;

	cout << "Student # " << i+1 << ":\n";
	cout << "Enter the FIRST NAME of student # " << i+1 << ":";
    cin  >> entry.name.first;

	cout << "Enter the LAST NAME of student # " << i+1 << ":";
    cin  >> entry.name.last;

	cout << "Enter the NID of student # " << i+1 << ":";
	cin >> entry.nid;

	cout << "Enter the SCORE of student # " << i+1 << ":";
    cin  >> entry.score;
    
	return entry;
	system("PAUSE");
}
This article has been dead for over six months. Start a new discussion instead.