229k views
2 votes
Write a rainfall class that stores the total rainfall for each of 12 months into an array of doubles

1 Answer

4 votes

Answer:

class Rainfall {

public:

// Constructor

Rainfall();

// Accessor functions

double getTotal() const;

double getAverage() const;

double getMonthlyTotal(int month) const;

double getMostRainfall() const;

double getLeastRainfall() const;

void print() const;

// Mutator functions

void setMonthlyTotal(int month, double rainfall);

private:

static const int MONTHS_IN_YEAR = 12;

double monthlyRainfall[MONTHS_IN_YEAR];

};

User Bemwa Malak
by
4.5k points