Help with this C++ program?
I am supposed to create a program that outputs a table of numbers and a set of calculations performed on them. The user will enter a (type double) starting point (at least 0.0, with 1 digit after the decimal point) and an integer telling how many lines they would like the table to be. Using a for-loop (controlled by the number of lines), you are to output the
following table of values for each “n”:
n, n^2 , n^3, squareroot of n. cube root of n, ceil(n), floor (n)
Here is my code
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
double startingPoint;
int numberOflines;
cout << "Enter starting point at least 0.0, with 1 digit after the decimal point."<<endl;
cout << "Where would you like to start?" <<endl;
cin >> startingPoint;
cout << "Please enter an integer telling how many lines you would like the table to be: " <<endl;
cin >> numberOflines;
cout <<"-------------------------------------… << endl;
return 0;
}
and here is my ouput which is a complete mess
Enter starting point at least 0.0, with 1 digit after the decimal point.
Where would you like to start?
2.0
Please enter an integer telling how many lines you would like the table to be:
3
Number Square Cubed Square Root Cube Root Ceiling Floor
--------------------------------------…
0.0 0.000 0.000 0.000 0.000
0. 0.
1.0 1.000 1.000 1.000 1.000
1. 1.
2.0 4.000 8.000 1.414 8.000
2. 2.
3.0 9.000 27.000 1.732 27.000
3. 3.
--------------------------------------…
Press any key to continue . . .
and its supposed to look like this
n squared cubed square-root cube-root ceiling floor
--------------------------------------…
2.0 4.000 8.000 1.414 1.257 2 2
2.1 4.410 9.261 1.449 1.277 3 2
What am i doing wrong?