GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 10-Dec-2004, 16:54
kakamuti kakamuti is offline
New Member
 
Join Date: Dec 2004
Posts: 5
kakamuti is on a distinguished road

Student ID/Grades program help...


OK So i have to do this program for school but im stuck...

here is the program description...


Objective:
This project will require you to put use the basic concepts of C programming covered in class. It will use control structures, logical operators, functions, array data structure and pointers in C.

Description:
Create a 10(rows)x5(columns) array to store student grades in four courses. The first column should contain the student_id ranging from 1001 to 1010. The remaining four columns will represent grades in Course1, Course2, Course3 and Course4. The values for this column will range from 0-100.

Do not accept values for this array from the user. Define the values for the array in your program with numbers that fall within the specified range. The program must be designed to display and handle the following menu options:
(a) Print the average of all courses for a specific student. Hint: In order to do this you will accept the student ID from the user and print the avg grade for that student.
(b) Print the average of all students for a specific course. Hint: In order to do this you will accept the Course Number from the user and print the avg grade for that course.
(c) Print the Grade in letter for a specific student and specific course. Hint: Accepts the StudentID and Course Number and convert the numerical grade for that course into a letter grade between A and F. Use the following grading system:

GRADE MARKS
A 100 – 91
B 90 - 81
C 80 – 71
D 70 – 61
F <= 60

(d) Modify the grades for a specific student in a specific course. Hint: Accept the StudentID , Course Number and new grade for that course and change the value in the array.
(e) Print all the students and grades for each student in a tabular format with all data right aligned.

Each menu option must be defined as a function. Use a switch-case structure to process the option input and invoke the corresponding function. The program must also accept appropriate input for the option and pass it as an argument to the appropriate function. The function must take care of all the printing needs for that menu option.

For menu option (d), pointers must be used to modify the grade of the student in the specified course. The numerical grade must be accepted from the user and also a check must be done to ensure that the value is between 1- 100. If it is not, the user must be prompted to re-enter a new value until it fits the requirement.

For menu option (e), use proper format spefications in printf() to print a table and all values in the table to be right aligned as follows:

Code:
StudentID | Course1 | Course2 | Course3 | Course4 | --------------------------------------------------------------- 1001 | 75 | 75 | 75 | 75 | 1002 | 70 | 100 | 80 | 65 | .. | ... | .. | .. | .... |










Here is the code i have so far...

CPP / C++ / C Code:
#include <stdio.h>

#define ROWS 10
#define COLUMNS 5

int a_courses_average
int b_students_average
char c_letter_grade
int d_modify_grade
int e_table

main()
{

	char option;

	int a[ROWS][COLUMNS]={0,1,2,3,4,1001,33,32,39,41,1002,
		55,34,47,53,1003,41,33,25,49,1004,25,29,37,19,1005,
		52,50,31,54,1006,37,39,12,22,1007,35,39,41,27,1008,
		29,33,37,46,1009,44,34,25,5,1010,100,99,99,100};
	
	printf ("Choose from the following options:\n");
	printf("a) Print the average of all courses for a specific student.\nb) 
		Print the average of all students on a specific course.\nC) Print the 
		Grade in letter of a specific student and specific course.\nd) Modify 
		the grades of a specific student in a specific course.\ne) Print all the
		students and grades of each student in tabular format with all data right
		aligned.\nAny other button will exit\n");
		scanf("%c", &option);

	switch (option){
	case a:	return a_courses_average;
		break;
	case b:	return b_students_average;
		break;
	case c:	return c_letter_grade;
		break;
	case d:	return d_modify_grade;
		break;
	case e:	return e_table;
		break;
	default: return 0;
		break
	}






}

int a_courses_average(int i)
{

	int id;

	printf ("Enter student ID between 1001-1010");
	scanf ("%d",&id);

	for (i=0;i<ROWS;i++)
		for(j=0;j<COLUMNS;j++)
			a[i][j]


}

int b_students_average()
{

}

char c_letter_grade()
{

}

int d_modify_grade()
{

}

int e_table()
{

}








I don't really know how to keep going, If anyone can help me with this or do it for me I would appreciate it more than you can ever imagine. Thanks
Last edited by JdS : 10-Dec-2004 at 23:00. Reason: Please insert [c] & [/c] tags between your example C codes
  #2  
Old 10-Dec-2004, 21:46
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,373
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by kakamuti
I don't really know how to keep going, If anyone can help me with this or do it for me I would appreciate it more than you can ever imagine. Thanks
Welcome kakamuti. Hope we can get you going!

First, use code tags (read the stickey) so we can read your code.
Second, why can't you keep going? What is the problem you're facing? Where are you stuck? What does the code actually do now and what should it be doing?

We need specific information and direction to know what the problem is, since we didn't write the code.

And please, NEVER ask us to do it for you. I've already graduated and don't need the grade. Others have their own homework to do. And I would guess that the going rate for consultant programmers is probably out of your reach
__________________

The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
  #3  
Old 07-Dec-2005, 16:06
snaoum snaoum is offline
New Member
 
Join Date: Dec 2005
Posts: 4
snaoum is on a distinguished road

Re: Student ID/Grades program help...


i've got the same project to do and i cant seem to figure it out, any one have the solution?
  #4  
Old 07-Dec-2005, 19:26
Paramesh's Avatar
Paramesh Paramesh is offline
Regular Member
 
Join Date: Sep 2005
Location: The Milky Way
Posts: 929
Paramesh is a jewel in the roughParamesh is a jewel in the roughParamesh is a jewel in the rough

Re: Student ID/Grades program help...


Hi kakamuti,

You miss semicolon at the end of the statements.
And declare the functions how you would use it.
some like:
CPP / C++ / C Code:
int courses_average(int a[10][5]);
int b_students_average(int a[10][5]);   
......

First declare a character c before you use it.
and As you learnt in your previous thread, Dont use scanf to get a character.
Use getchar, as WaltP said, like this:
CPP / C++ / C Code:
c = getchar();
while (getchar() != '\n');

Regarding two dimensional array, you can be more clear like this kind:
CPP / C++ / C Code:
    int a[ROWS][COLUMNS]={ {1001,33,32,39,41},
                          {1002,55,34,47,53},
                          {1003,41,33,25,49},
                                ......

And in the switch case statement, you should do something like this:
CPP / C++ / C Code:
switch(c){
    case 'a':    
        printf(" The courses average is %d", a_courses_average(a));
        break;
    case 'b':
        printf("The students average is %d", b_students_average(a));
        break;
......

Regards,
Paramesh.
__________________

Don't walk in front of me, I may not follow.
Don't walk behind me, I may not lead.
Just walk beside me and be my friend.
  #5  
Old 07-Dec-2005, 19:29
snaoum snaoum is offline
New Member
 
Join Date: Dec 2005
Posts: 4
snaoum is on a distinguished road

Re: Student ID/Grades program help...


anyone have this program or solution, i would be willing to pay someone to get me this program.
  #6  
Old 07-Dec-2005, 19:32
Paramesh's Avatar
Paramesh Paramesh is offline
Regular Member
 
Join Date: Sep 2005
Location: The Milky Way
Posts: 929
Paramesh is a jewel in the roughParamesh is a jewel in the roughParamesh is a jewel in the rough

Re: Student ID/Grades program help...


We have no solution or program, and we wont do it for you.

Why dont you do this program yourself?
We can to guide you.


Paramesh.
__________________

Don't walk in front of me, I may not follow.
Don't walk behind me, I may not lead.
Just walk beside me and be my friend.
  #7  
Old 07-Dec-2005, 19:34
snaoum snaoum is offline
New Member
 
Join Date: Dec 2005
Posts: 4
snaoum is on a distinguished road

Re: Student ID/Grades program help...


i wish i could, im soo bad in C, i dont even know where to start, im trying to graduate this semester and this is soo useless to me, doesnt even have anyhting to do with my major just need to due this and pass.
  #8  
Old 07-Dec-2005, 21:11
snaoum snaoum is offline
New Member
 
Join Date: Dec 2005
Posts: 4
snaoum is on a distinguished road

Re: Student ID/Grades program help...


Code:
#include <stdio.h> #define ROWS 10 #define COLUMNS 5 int courses_average(int a[10][5]); int b_students_average(int a[10][5]); c = getchar(); char c_letter_grade int d_modify_grade int e_table main() { char option; int a[ROWS][COLUMNS]={0,1,2,3,4,1001,33,32,39,41,1002, 55,34,47,53,1003,41,33,25,49,1004,25,29,37,19,1005, 52,50,31,54,1006,37,39,12,22,1007,35,39,41,27,1008, 29,33,37,46,1009,44,34,25,5,1010,100,99,99,100}; printf ("Choose from the following options:\n"); printf("a) Print the average of all courses for a specific student.\nb) Print the average of all students on a specific course.\nC) Print the Grade in letter of a specific student and specific course.\nd) Modify the grades of a specific student in a specific course.\ne) Print all the students and grades of each student in tabular format with all data right aligned.\nAny other button will exit\n"); switch(c){ case 'a': printf(" The courses average is %d", a_courses_average(a)); break; case 'b': printf("The students average is %d", b_students_average(a)); break; case 'c': printf("The letter grade is %d, c_letter_grade(a)); break; case 'd': printf("The modify grade is %d, d_modify_grade(a)); break; case 'e': printf("Table %d, e_table(a)); break; default: return0; break; } } int a_courses_average(int i) { int id; printf ("Enter student ID between 1001-1010"); scanf ("%d",&id); for (i=0;i<ROWS;i++) for(j=0;j<COLUMNS;j++) a[i][j] } int b_students_average() { } char c_letter_grade() { } int d_modify_grade() { } int e_table() { }
  #9  
Old 08-Dec-2005, 08:31
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,310
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Student ID/Grades program help...


Quote:
Originally Posted by kakamuti

here is the program description...

Objective:
This project will require you to put use the basic concepts of C programming covered in class. It will use control structures, logical operators, functions, array data structure and pointers in C.

So use class notes, previous assignments, textbook examples, etc. to proceed

Quote:
Originally Posted by kakamuti
Description:
Create a 10(rows)x5(columns) array to store student grades in four courses. The first column should contain the student_id ranging from 1001 to 1010. The remaining four columns will represent grades in Course1, Course2, Course3 and Course4. The values for this column will range from 0-100.

I don't really know how to keep going, If anyone can help me with this ...I would appreciate it

Instead of trying to write the whole thing all at once, I would do it one thing at a time. Make sure each step is correct (make a complete program and test it) and then go on to the next.


Here is a possible approach:

For example the very first thing: make an array.

Now, Paramesh has given you a hint that lets us humans see a little more clearly what the 2-D array looks like. I have reformatted your code (but haven't changed it). The compiler will accept this or it will accept it the way that you wrote it (just enter a comma-delimited list of all of the elements). Doing it this way makes it easier for me to see exactly what is on each row. This makes editing and debugging easier (for me, at least).

CPP / C++ / C Code:
#include <stdio.h>

#define ROWS 10
#define COLUMNS 5

main()
{

  int i;
  int j;

  int a[ROWS][COLUMNS]={{   0,   1,  2,  3,  4},
                        {1001,  33, 32, 39, 41},
                        {1002,  55, 34, 47, 53},
                        {1003,  41, 33, 25, 49},
                        {1004,  25, 29, 37, 19},
                        {1005,  52, 50, 31, 54},
                        {1006,  37, 39, 12, 22},
                        {1007,  35, 39, 41, 27},
                        {1008,  29, 33, 37, 46},
                        {1009,  44, 34, 25,  5},
                        {1010, 100, 99, 99,100}
                        };

  for (i = 0; i < ROWS; i++) {
    for (j = 0; j < COLUMNS; j++) {
      printf("%4d\n", a[i][j]);
    }
  }
  return 0;
}

Now compile this. You will get an error. How many rows did you declare? How many rows are in the array?

Once you understand how to allocate and print a 2-D array, then go on to the next step. As you add new things, recompile often to eliminate syntax errors. When you have enough new stuff to test, stop coding and start testing.

As you complete each task, save the program (under a different name), so that if you add a bunch of stuff that turns out to be a Bad Idea, you can fall back to a previous known good state.

Regards,

Dave
  #10  
Old 08-Dec-2005, 10:48
Sokar Sokar is offline
Member
 
Join Date: May 2005
Posts: 243
Sokar has a spectacular aura aboutSokar has a spectacular aura about

Re: Student ID/Grades program help...


This thread has been brought back from the dead, it is a year old.
Date of WaltP post,
10-Dec-2004 23:46
 
 

Recent GIDBlogProblems with the Navy (Officers) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[TUTORIAL] Calling an external program in C (Linux) dsmith C Programming Language 4 22-Apr-2005 13:30
fltk-2.0 cvs Plumb FLTK Forum 20 13-Nov-2004 07:10
Anyone can write a program code for this??? chriskan76 C Programming Language 1 19-Oct-2004 20:25
C binary file program Newworld C Programming Language 5 11-Oct-2004 19:43
Need help with a C program (Long) McFury C Programming Language 3 29-Apr-2004 20:06

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 05:28.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.