Assignment Help

Write a complete program that will create a table as follows: The table will have 5 columns headed by: NUMBER, DIVIS3, DIVIS5, SQROOT, and FRTHROOT defined as follows:

• NUMBER generate the odd numbers from 15 to 53 (inclusive)
• DIVIS3 if the number is divisible by 3, then put a * in this column
• DIVIS7 if the number is divisible by 7, then put a * in this column
• SQROOT the square root of the number in the NUBMER column
• FRTHROOT the fourth root of the number in the NUBMER column (the square root of the square root is the fourth root)


After the table has printed, skip several lines and print the following:

• The number of numbers that are divisible by 3
• The number of numbers that are divisible by 7
• The average of the numbers that are divisible by both 3 and 7.
• The average of the square roots (of all the numbers).
• The sum of the numbers in the NUMBER column
• The sum of the numbers in the SQROOT column
Last edited on
This is what I have so far..but it's only because the professor did most of it. I don't understand how to use the functions.

#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int i;
int numNumbers = 0;
int div3 = 0;
int div7 = 0;
int sum = 0;
float sumSqrt = 0.00;


cout << "Number" << "\t" << "div3" << "\t"
<< "div7" << "\t" << "Sqrt" << "\t"
<< "4throot" << endl ;

for (i = 15; i <= 53; i = i +2){
cout << i;
numNumbers ++;
sum = sum + i;
if (i%3 == 0){
cout << "\t" << "*";
div3 ++;
}
else cout << "\t" << " ";
if (i%7 == 0){
cout << "\t" << "*";
div7 ++;
}
else cout << "\t" << " ";
if (i%3 == 0 && i%7 == 0){
/* put a count and a sum here - get rid of cout */
cout << "if is div by both 3 and 7 " << endl;
div3 ++;
div7 ++;
}
cout << "\t" << sqrt (i);
sumSqrt = sumSqrt + sqrt(i);
cout << "\t" << sqrt(sqrt(i)) << endl;

}
/* after the loop */
// now we print totals and counters and averages

cout << "sum of the numbers " << sum << endl;
cout << "sum of the sq root " << sumSqrt << endl;
cout << "# of numbers " << numNumbers << endl;
cout << "Avg of Sq roots " << sumSqrt / numNumbers << endl;
cout << "# of numbers divisible by 3" << numNumbers
/* print counters div3 and div7 */




return 0;
}
Topic archived. No new replies allowed.