Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part 1- Program Description and Requirements Problem: You are to create a progra

ID: 3671928 • Letter: P

Question

Part 1- Program Description and Requirements Problem: You are to create a program that outputs a table of numbers and a set of calculations performed on them. The user will enter a starting point and the number of lines they would like to include in the table. Using a for-loop (controlled by the number of lines), you are to output the following table of values for each "n", increasing n by 0.1 each time: Vn 3 Vn ceiling(n) floor(n) This process will be repeated using a do...while loop (not a while loop) until the user enters O for the number of lines. In other words, repeat the following until the user enters 0 for the number of lines: aslk the user for the starting point, ask the user for the desired number of lines, perform necessary calculations and output the table using a for-loop. For example, here is the output for 8 lines starting at 2.0 for a single iteration of the do...while loop. Please enter a starting value 2.0 Please enter a maximum for your table n 3 square-root cube-root ceiling floor 8,0000 9,2610 2.2 4,8400 10.6480 12.1670 7600 13.8240 15,6250 17.5760 2.7 7.2900 19.6830 1.4142 1.4491 1.4832 1 , 5166 1 , 5492 1.5811 1.6125 1 , 6432 2.0 4,0000 2.1 4.4100 1 , 2599 1.2806 1,3006 1,3200 1.3389 1,3572 1,3751 1,3925 2.3 5,2900 2.4 5,7600 13 2.5 6,2500 2.6 6,7600 Requirements: 1. The starting point entered by the user will be a double, and must be at least 0.0. Perform input validation to ensure that a negative number is not entered. If a negative number is entered, inform the user and ask for a new input for the starting point. a. 2. The number of lines to output in the table will be an integer. Since we are using a do...while loop, if the user enters 0 for the number of lines, the loop will execute no matter what. You can handle this by printing "Goodbye!" and exiting the program if the user enters 0. a. 3. You must use both the for-loop and do...while-loop as described above. You must not control your for loop with a non-integer value. Think about how to control the for loop with the number of lines (an integer). a. As in the example, the output for the first column should contain 1 digit after the decimal point the output in the next 4 columns should each contain 4 digits after the decimal point, and the ceiling and floor should be outputted as integers (no decimal point). Use functions for each of the calculations. 4. 5,

Explanation / Answer

#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

int main()
{
double n;
int NofLines;
int UserInput;
int i=1;
do{
do{
cout << "Please enter the positive number" << endl;
cin >> n;
}while(n<0);
cout << "enter number of line to print" << endl;
cin >> NofLines;
cout << "n square cube sroot ct ceil fl" << endl;
cout << "-------------------------------------------------------------------------------" << endl;

do{

cout <<n<<" "<<n*n<<" "<<n*n*n<<" "<<sqrt(n)<<" "<<std::pow(n,1/3)<<" "<<ceil(n)<<" "<<floor(n)<<endl;
n+=0.1;
i++;
}while(i<=NofLines);
cout << "Enter the positive number again"<<endl;
cin>>n;
}while(n>0);
cout << "Good Bye!" << endl;

return 0;
}