trying to figure this out

I'm looking for some guidance on this one please if you know where on this website i can see examples on how to do it please

You are to write a Class called Student. This class should have only 2 variables:
string name;
double gpa;
You should have a default constructor and one which has the name passed in through the arguements.
The constructor will assign the gpa using the rand() function, it should be in the range of 0.0 - 4.0 (one decimal place only). ** rand() generates int values, good luck figuring out math required to get the gpa in the correct double range **

There should be a get and set function for all the variables as well as a display function which will display both the person's name and gpa.

In the main, you should create an array of 5 people. Ask the user to input the five names and pass them to the correct array element. Make sure to use a loop for this step.
Display everyone's information first. After, locate the person with the highest gpa and display that person's information again. **In case of multiple people get the same highest gpa, display all people with highest gpa *


here is what I have so far not sure how to put it together or how to add the arrays

#include <iostream>
#include <string>
using namespace std;

class Student
{
string name;
double gpa;



Student(int y = 0.0 < 4.0);
{ gpa = y; }


int main()
{
const int Student = 5;
Last edited on
First of all:
assigment wrote:
You should have a default constructor and one which has the name passed in through the arguements.
THere should not be any constructors receiving an int.

I see, you are strugling with basic class features, so here is links which can help you:
http://www.cplusplus.com/doc/tutorial/classes/
http://www.learncpp.com/cpp-tutorial/82-classes-and-class-members/

To have rand() generate random value from 0.0 to 4.0 with 1 decimal space precision:
double x = (rand() % 41) / 10.0;
Topic archived. No new replies allowed.