#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main ()
{
int numb, sum, divis3, divis5;
numb = 20;
sum = 0;
double value = sqrt(numb);
cout.setf(ios::fixed,ios::floatfield);
cout << setw(8) << left << "NUMBER"
<< setw(8) << left << "DIVIS3"
<< setw(8) << left << "DIVIS5"
<< setw(8) << left << "SQROOT"
<< setw(8) << left << "FRTHROOT\n" << endl;
while (numb <=60) {
numb = numb +2;
value = sqrt(numb);
divis3 = divis3;
divis5 = divis5;
cout.setf(ios::fixed,ios::floatfield);
cout << setw(8) << numb ;
if (numb%3==0) {
cout << setw(8) << "*";
divis3 = divis3 +1;
}
else
cout << setw(8) << " " ;
if (numb%5==0) {
cout << setw(8) << "*" ;
divis5 = divis5 +1;
}
else
cout << setw(8) << " ";
cout << setw(8) << setprecision(3) << value ;
cout << setw(8) << setprecision(3) << sqrt(value) << endl;
}
cout << endl << "The number of numbers divisible by 3 is " << divis3 << "." << endl;
cout << "The number of numbers divisible by 5 is " << divis5 << "." << endl;
cout << "The average of the numbers divisible by both 3 and 5 is " << "." << endl;
cout << "The average of the square roots is " << "." << endl;
cout << "The sum of the numbers is " << "." << endl;
cout << "The sum of the square roots is " << "." << endl;
return 0;
}
It was working, until I was messing around trying to get the average of the numbers divisible by both 3 and 5 (next on the list) -- needless to say, that didn't work (or I would have kept it in), and not only that -- but now my count goes to <=62. I can't find what the f is wrong. It explicitly states, <=60. What's wrong?
Besides/after that, how do I work out the rest of that list? (How do I find the average of the numbers divisible by both 3 and 5, the average of the sqrts, the sum of the numbers, and the sum of the sqrts?)
Thanks so much.