I'm trying to write a program that will calculate rations, max, min, total and average #. I'm told I can use #include <algorithm> but I don't know how to use it. I need it to spit out something similar to the following:
How many in the first category? 8 cats
How many in the second category? 12 dogs
cats 8
dogs 12
cat to dog ration 0.67
dog to cat ratio 1.50
max 12
min 8
total 20
average 10.00
I need to express ratios by exactly 2 decimal places and so I think I need to use the set precision, correct me if I'm wrong.
The program is supposed to run forever, but I ended it with return 0; because thats all I know how to close it with. I'm new at this C++ thing and I tried starting and have miserably failed. Here is a start of a new attempt and trying to get the average but I'm confused about how to calculate it.
Any help is greatly appreciated!
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{
int athletes;
cout << "Please enter the number of athletes: ";
int a1;
cin >> athletes;
int coaches;
cout << "Please enter the number of coaches: ";
int c1;
cin >> coaches;
double total = a1 + c1
double average = (total)/ 2.0;
cout << "average" << average << "\n";
return 0;
}