Hi Guys,
Last question on this if I may?
Tried to take your points on board and looked around and now have my program working that works out the lowest number, highest number, mean and sum. Here's the code:
Code:
// Determining the largest number
#include <iostream>
using namespace std;
#include <string>
class figures
{
public:
int get_largest_number(int a[]);
int get_smallest_number(int a[]);
int get_sum_number(int a[]);
int get_mean_number(int a[]);
int get_histogram(int a[]);
protected:
int largest_number;
int smallest_number;
int i;
int mean;
int sum;
};
int figures::get_largest_number(int a[]) {
for(i=0; i<20; i++)
{
cout << "Enter Number: " << i + 1 << ") ";
cin >> a[i];
cin.ignore();
if(a[i] > largest_number)
{
largest_number = a[i];
}
}
return largest_number;
}
int figures::get_smallest_number(int a[])
{
for(i=0; i<20; i++)
{
if(a[i] < smallest_number)
{
smallest_number = a[i];
}
}
return smallest_number;
}
int figures::get_sum_number(int a[])
{
int sum = 0;
for ( int i = 0; i < 20; i++ )
{
sum += a[i];
}
return sum;
}
int figures::get_mean_number(int a[])
{
return get_sum_number(a) / 20;
}
CPP File
Code:
// ASSIGN77.CPP
// A Program to display the largest number
#include "values3.h"
#include <cstdlib>
int main ()
{
int a[20];
figures numbs;
cout << "The largest number is " << numbs.get_largest_number(a) << endl;
cout << "The smallest number is " << numbs.get_smallest_number(a) << endl;
cout << "The sum of the numbers is " << numbs.get_sum_number(a) << endl;
cout << "The mean of the numbers is " << numbs.get_mean_number(a) << endl;
cin.get();
return 0;
system ("pause");
}
Now i'm really happy I have it working, but now I want to create a Histogram if possible, but the only reference I can find is Here which confused me big time!
Now I want it to output like:
Range 0-9: ****
Range 10-19: **
Can anyone point me in the right direction and if this is simply done as what I have looked at so far is very confusing!
Thanks
Chris