Hi! I am pretty behind in my c++ class and trying to finish a lab. The instuctions are below. I'm not looking for a whole coded answer because I want to learn it, but honestly I'm not sure what to do first. I think I have the concept of classes down, but the functions and arrays are still hard for me.
Any advice on how to start and what this code might look like would be fantastic!
I am also new to this website so I'm sorry if this isn't the right forum for this question :)
Write a class named students that has the following member variables:
▪ name — a string that holds the student’s name
▪ exam1 — a double that holds the first exam score
▪ exam2 — a double that holds the second exam score
Ask the user to enter three student’s information and calculate their exam
average as follows:
Hint: There should be at least five-member functions.
What I have so far:
#include <iostream>
#include <string>
using namespace std;
class Students
{
private:
string name;
double exam1;
double exam2;
public:
void getexam1(double);
void getexam1(double);
double getexamaverage(); //returns the average of the exam grades
I'd rename class Students as Student - as it only holds data for 1 student. Also there are two getexam1() functions!
I'd then have an array of Student that has 3 elements in main() (students possibly).
Then iterate over the array to obtain the data (call the class get input functions) and then iterate again over the array to calculate and display the averages (call class get average function).
Use a for loop to iterate over an array.
Note that if an array has 3 elements, it's first element is element 0 and it's last element is element 2.