Help WIth program for class

Hello Everyone, I am very new to programming and have fell a bit behind in class. I am reading my book to try to catchup for the final on Wednesday. However, I seem to have hit a wall between what i already know and how long it will take me to figure out the knowledge needed to write our last program. The last program builds from our previous program from what i can see and if anyone could so help me, i would like to paste the teachers expectations for the program as well as what i had written for my past program to have it edited. I know its a tall order and a common due my homework for me kinda move. But i really am in a bind here and i am trying to learn its just taking longer then i thought. I Noted my last program so that my teacher could see i understood what was happening so sorry for the extensive noting and for anyone who can help make my old program into the standard of the new one, I Thank You greatly! See below

Teachers assignment:
Write a C++ program that accepts three grades (whole numbers) from the keyboard for any number of students, with the maximum number of students that can be entered is 30 students. For each student, it calculates the average of the three grades and the equivalent letter grade. After reading the grades,
processing the average and the letter grade, it prints out the student number, the three grades, the average, and the equivalent letter grade to the screen. You program should define a function-template the will be used for a function to calculate the average grade for three grades (10 points). Your program
should also use two functions, one to find the highest average-grade in class and another function to find the least average-grade in class (10 points). In addition, your program will calculate the class average (the average of averages) and prints the result to the screen (10 points). Make sure to
document your program and functions by adding multi-lines comment that describe what each function is doing. Do not forget to include your name at the top of the program (10 points). You should utilize one-dimensional arrays data structure for your variables (10 points).


My last code i created:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
  //Beau B
//Programing 1 - Assignment 2
//Due date 9/30/14

#include "stdafx.h"
#include <iostream> // Allows program to perform input and output.

using namespace std; // allows using cin and cout rather then std::cin and std::cout.

// Function main begains program execution.
int main()
{ // Starts function.

	//Veriable declarations.
	double Grade1; // Stores First grade in loop.
	double Grade2; // Stores Second grade in loop.
	double Grade3; // Stores Third grade in loop.
	double AvgGrade; // average of entered grades.
	double Total = 0; // Stores Combined value of grades per loop.
	double AverageTotal = 0; // Holds running total of grades, Used for final Average.
	int Students = 0; // Stores input of amount of students, Used to stop Counter.
	int n = 0; // Used to calculate counter position.
    int StudentNumber; // Used to output which student data is being requested for.

	cout << "Enter the number of students in class : "; // Request amount of students for loop from user.
	cin >> Students; // Store user entered value of students.

	

	// used to vary the allowed amount of students based on user needs.
	while (n < Students) {

		StudentNumber = n + 1; // Calculate current Student number position.

		cout << "Please enter three numeric grades for student number " << StudentNumber << ". "; // requesting grades imput from user.
		cin >> Grade1; // Placing users first grade value to Grade1.
		cin >> Grade2; // Placing users second grade value to Grade2.
		cin >> Grade3; // Placing users third grade value to Grade3.
		
		Total = (Grade1 + Grade2 + Grade3); // Calculate current grade total.
		AverageTotal = AverageTotal + Total; // Store total grade for running total.
		AvgGrade = (Total / 3); // Calculate average grade.

		cout << "Student number " << StudentNumber << " grades: " << Grade1 << " " << Grade2 << " " << Grade3 << " average: " << AvgGrade << " "; // Output data to user about Grades using calculations of stored values.
		
		n = n + 1; // add one to counter position. 

		// Selection of grade based on callculation of AvgGrade to display designated letter grade output.
		if ( AvgGrade >= 90) // Grades 90 and above as "A"
			cout << " letter grade: A!\n";
		else
			if ( AvgGrade >= 80) // Grades 80-89 as "B"
				cout << " letter grade: B.\n";
			else
				if ( AvgGrade >= 70) // Grades 70-79 as "C"
					cout << " letter: grade: C.\n";
				else
					if ( AvgGrade >= 60) // Grades 60-69 as "D"
						cout << " letter grade: D.\n";
					else // Grades 59 and less as "F"
						cout << " letter grade: F.\n";
		cout << "\n"; // Adds new line between data to improve readability of program.
	}
		
	cout << "The class average: " << AverageTotal / (StudentNumber * 3) << "\n" ; // displays total class average based on running total and about of studends.
	
	// Allows user to view data by creating a stop, user pressed key to return 0 value and exit program.
	system("PAUSE"); 
	return 0;
	exit(1);
	
}

Please help!
Use struct like this
1
2
3
4
5
struct Student{
  int grade1,grade2,grade3;
  float average;
  char letterAv
};

Then create 1 dimensional array of that struct
1
2
cin>>numof_students;
Student student[numof_students];

Next use for loop to get the input
1
2
3
4
5
6
7
for(int i=0;i<numof_students;i++){
  cin>>student[i].grade1;
  cin>>student[i].grade2;
  cin>>student[i].grade3;
  student[i].average= //you know what to do here
  //i think you also know that you need to do with student[i]letterAv
}

And last for a class average its simple use for loop up to numof_student and use += to each student[].average to get the total average in class, next divide total average with numof_student
Last edited on
Thank you.
Topic archived. No new replies allowed.