943,558 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 943
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Apr 28th, 2009
0

Difficult programming challenge

Expand Post »
I have a very hard programming challenge and i need help... I have nothing so far, so im hoping somebody could help me build it...

Im to write a program that uses a structure to store student name, student ID number, pointer to and array of test scores, average test score, and course grade.
Program should keep list of tests scores for a group of students, ask the user for how many test scores and how many students there are. It should then dynamically allocate (pointer?) and array of structures. Each structure's test menber should point to a dynamically allocated array (pointer?) which will hold the tests scores.

After this, program should ask for ID number and test scores for each student. Average test score should be calculates and stored in the average member of each structure. score grade should be computed (91-100=A and so on).

Score grade should then be stored in the Grade member of each structure...once data is calbulated, a table should show student's name, ID number, average test score, and course grade...

These are the instructions, from what I understand, I think it should look like this...

ask for students...
ask for test scores..
build arrays

student 1: ID? name?
test1:
test2:

student2: ID?Name?
test1:
test2:


something like that...help!!!
Last edited by pt_solar; Apr 28th, 2009 at 1:28 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pt_solar is offline Offline
23 posts
since Mar 2009
Apr 28th, 2009
0

Re: Difficult programming challenge

That looks suspiciously like a homework question. Perhaps you should give a shot at coding it a bit yourself before we give you a hand.
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005
Apr 28th, 2009
0

Re: Difficult programming challenge

Click to Expand / Collapse  Quote originally posted by pt_solar ...
I have a very hard programming challenge and i need help... I have nothing so far, so im hoping somebody could help me build it...
> Doesn't sound very difficult

> Sure we can help you as long as you can show us what you've already done and ask us specific questions about what you don't understand ...
Reputation Points: 2125
Solved Threads: 243
Postaholic
tux4life is offline Offline
2,105 posts
since Feb 2009
Apr 28th, 2009
0

Re: Difficult programming challenge

Okay I will try thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pt_solar is offline Offline
23 posts
since Mar 2009
Apr 28th, 2009
0

Re: Difficult programming challenge

this assignment has never been given before!!!!11
Reputation Points: 2143
Solved Threads: 178
Posting Maven
jephthah is offline Offline
2,567 posts
since Feb 2008
Apr 28th, 2009
0

Re: Difficult programming challenge

> Whether it's his homework or not, he'll first have to show us his code ...
Reputation Points: 2125
Solved Threads: 243
Postaholic
tux4life is offline Offline
2,105 posts
since Feb 2009
Apr 28th, 2009
0

Re: Difficult programming challenge

I would sugguest attending class.
Reputation Points: 352
Solved Threads: 108
Master Poster
skatamatic is offline Offline
772 posts
since Nov 2007
Apr 28th, 2009
0

Re: Difficult programming challenge

Poor me ! it's an online class, it was the only option and the teacher sucks. We have a tutor that's a fellow student and he couldn't even help me do this one . So please help with whatever hints you can give me Here's what I have:

#include <iostream>
using namespace std;

const int NAME_LENGTH= 80;
const int SIZE;

struct studentData
{
	char studentName[NAME_LENGTH];
	int Idnum;
	int numTests;
	int *testsPtr;
	double Average;
	char Grade[SIZE];
};

int main()
{
	cout<<"How many test scores are there?"<<endl;
	cin>> numTests;
	
	cout<< "How many students are there?"<<endl;
	cin<< numStudents;

	studentData *students;
	students = new student[numStudents];
	for (int count=0; count<numStudents;count++)
	{
		cout<<"Enter the Test scores for student number "<<(count+1)<<endl;
		for (int count=0; count<Tests; count++)
		{
			cout<< "Enter test score #"<<(count+1)<<": "endl;
			cin>> Tests[count]
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pt_solar is offline Offline
23 posts
since Mar 2009
Apr 28th, 2009
0

Re: Difficult programming challenge

Okay I guess my first question is how do I dynamically allocate an array of structures correctly and how do I get each structure's tests to point to a dynamically allocated array that hold these test scores?
I have no idea hat to do from here on Please help:

#include <iostream>
using namespace std;

const int NAME_LENGTH= 80;
const int SIZE;

struct StudentData
{
	char studentName[NAME_LENGTH];
	int Idnum;
	int numTests;
	int *testsPtr;
	double Average;
	char Grade[SIZE];
};

int main()
{
	cout<<"How many test scores are there?"<<endl;
	cin>> numTests;
	
	cout<< "How many students are there?"<<endl;
	cin<< numStudents;

	StudentData *testsPtr;
	testsPtr = new StudentsData[numStudents];
	for (int count=0; count<numStudents;count++)
	{
		cout<<"Enter the Test scores for student number "<<(count+1)<<endl;
		for (int count=0; count<Tests; count++)
		{
			cout<< "Enter test score #"<<(count+1)<<": "endl;
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pt_solar is offline Offline
23 posts
since Mar 2009
Apr 29th, 2009
0

Re: Difficult programming challenge

Is this the total number of test scores for ALL students combined or for EACH student?

C++ Syntax (Toggle Plain Text)
  1. cout<<"How many test scores are there?"<<endl;
  2. cin>> numTests;

And does each student have the same number of test scores or does it vary from student to student? Also, what does SIZE represent here?

C++ Syntax (Toggle Plain Text)
  1. const int SIZE;
Last edited by VernonDozier; Apr 29th, 2009 at 1:09 am.
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is online now Online
5,371 posts
since Jan 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: help me searching struct arrays
Next Thread in C++ Forum Timeline: This confuses me so much that I don't even know what to call the problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC