0

Hello there everyone before I post my ( probably not elegant) code I Would like to first give the community an idea of what I am doing. I am writing a grade organizer program to where I can store a test, lab, or homework grade respectively. I have finished the portion of this project where I can input the data and have even displayed it during the input to make sure that the data was being stored into the structure properly. I need some help with a few things here, first things first I need help with linked lists, quite frankly i'm a year's worth out of practice in C++ and would like some assistance maybe turning these structures into functional linked lists. The second question I am asking is how would I write this to a file assuming I actually wanted to make this program a usable Executable without a compiler handy. In otherwords it would be nice if I Could store the nodes in the linked list and be able to open and save them when needed. I apologize if I'm a little vague here, I have done some snooping online and have found little help, even if you guys had a few helpful links to what I am looking for that would be most helpful.

Now without further hesitation, THE CODE:

#include <iostream>
#include <string>
using namespace std;
struct T_storenode{                   // Structure to create a record of a tests name,score,and weight in final grade;
	char name[30];
	char date[30];
	float score;
	struct node *next;
}T_value[250];                    // array for the structure.
struct L_storenode{
	float score;
	char name[30];
	char date[30];
	struct node *next;
}L_value[250];
struct H_storenode{
	char name[30];
	char date[30];
	float score;
	struct node *next;
}H_value[250];
int OptionMenu(int);                                                        // menu proto
void GradeAve(float GA_number, float G_ave,float GA_sum, int GA_count);     // case 1 proto
void Tests_store(T_storenode test);                                            // case 2 proto
void Lab_store(L_storenode test);
 void HW_store(H_storenode test);
int main()
{   float GA_sum=0;                                                        // sum for case 1
    float GA_ave=0;                                                        // average for case 1
	int menunumber=0;                                                      // menu selection
	int GA_count=0;
	float GA_number=0;
	int menu_number_returned=0;                                            // menu value returned for switch statement.
	int T_count = 0;
 
   	menu_number_returned = OptionMenu(menunumber);  
	
	// call function to menu select and return value to menu_number_returned
	
	
	system("cls");                                                         // clear screen

	   
	switch(menu_number_returned)                                           // Switch statement to process the menu selection screen
	{
            case 1: 
			GradeAve(GA_number,GA_sum,GA_ave,GA_count);                    // menu selection 1 call; find average of a test score
			break;
			case 2:
			Tests_store(T_value[250]);                            // menu selection 2 call; still working on this...
			break;
            case 3:
            Lab_store(L_value[250]);
		    break;
			case 4:
			HW_store(H_value[250]);
			break;
			//case 5:
            //break;
			//case 6:
            //break;
			//case 7:
            //break; 
			default:
				cout<<"Exiting The Program"<<endl;
				exit;
			
}
system("pause");
return 0;
	    
}

	int OptionMenu(int menunumber)
	{
		cout<<"--------------------------------------------------"<<endl;
		cout<<"|          Welcome to the grade organizer!       |  "<<endl;
		cout<<"|             Written by: Michael Daly           | "<<endl;
		cout<<"--------------------------------------------------"<<endl;
        cout<<"Choose an option, or hit any other key to EXIT:\n\n\n1.) Compute grade average.\n\n2.) Store a test grade.\n\n3.) Store a Lab Assignment grade.\n\n4.) Store a Homework grade.\n\n5.) look up a test grade\n\n6.) Look up a Lab Assignment grade\n\n7.) Look up a Homework grade\n\n"<<endl;
	    cin>>  menunumber;
        return menunumber;
	}

	void GradeAve(float GA_number, float G_ave,float GA_sum, int GA_count)
	{


		cout<<"How many grades would you like to process?"<<endl;
		cin>>GA_count;
        system("cls");
		for(int i = 0;i<GA_count;i++)
		{   
			cout<<"Enter a grade:"<<endl;
			cin>>GA_number;
			GA_sum += GA_number;
			system("cls");
		}
        G_ave = GA_sum/GA_count;
        cout<<"The Sum of the grades entered is:   "<<GA_sum<<endl;
		cout<<"The Average is:   "<<G_ave<<endl;
        return;
	}
	 void Tests_store(T_storenode test)
	{
		
		int T_count = 0;
	  cout<<"How many tests are you planning on storing?:"<<endl;
	  cin>>T_count;
	  for (int index=0;index<T_count;index++)
	  {
	        cout<<"What is the name of the test?:"<<endl;
	        cin>>T_value[index].name;
			cout<<"What is the score of the test?:"<<endl;
			cin>>T_value[index].score;


}  
	  for (int name_check=0;name_check<T_count;name_check++)
	  {
		  cout<<"the test names entered are:"<<T_value[name_check].name<<endl;
		  T_value[name_check].name;
		  
	  }
	  for ( int score_check=0;score_check<T_count;score_check++)
	  {
		  cout<<"The scores entered are:"<<T_value[score_check].score<<endl;
	  }
	 
			return;
	 }



	  void Lab_store(L_storenode test)
	{
		int L_count = 0;
	  cout<<"How many Lab grade(s) are you planning on storing?:"<<endl;
	  cin>>L_count;
	  for (int index=0;index<L_count;index++)
	  {
	        cout<<"What is the name of the Lab Assignment?:"<<endl;
	        cin>>L_value[index].name;
			cout<<"What is the score of the Lab?:"<<endl;
			cin>>L_value[index].score;


}  
	  for (int name_check=0;name_check<L_count;name_check++)
	  {
		  cout<<"the Lab name(s) entered are:"<<L_value[name_check].name<<endl;
		  L_value[name_check].name;
		  
	  }
	  for ( int score_check=0;score_check<L_count;score_check++)
	  {
		  cout<<"The Lab scores entered are:"<<L_value[score_check].score<<endl;
	  }
	 
			return;
	 }



	 void HW_store(H_storenode test)
	{
		int H_count = 0;
	  cout<<"How many Lab grade(s) are you planning on storing?:"<<endl;
	  cin>>H_count;
	  for (int index=0;index<H_count;index++)
	  {
	        cout<<"What is the name of the Lab Assignment?:"<<endl;
	        cin>>H_value[index].name;
			cout<<"What is the score of the Lab?:"<<endl;
			cin>>H_value[index].score;


}  
	  for (int name_check=0;name_check<H_count;name_check++)
	  {
		  cout<<"the Lab name(s) entered are:"<<H_value[name_check].name<<endl;
		  H_value[name_check].name;
		  
	  }
	  for ( int score_check=0;score_check<H_count;score_check++)
	  {
		  cout<<"The Lab scores entered are:"<<H_value[score_check].score<<endl;
	  }
	 
			return;
	 }

Thanks in advance to anyone who took the time to read/help me with this! Thank you. Also I was wondering if you guys would be able to tell me at what level you think my program skills are for what I've written, obviously not the best but I'm hoping the community see's potential in me as a future programmer as I would love to do this for a living. Thanks everyone!

Edited by WaltP: Fixed CODE Tags -- use the PREVIEW button.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by daviddoria
0

My main comment is that I would definitely use STL vectors instead of all of your arrays - the memory is managed automatically, you can do bounds checking if you wish (with .at() ), you do not need to know/guess the size ahead of time, you can resize them, and the list goes on.

Dave

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.