Compute the width of each column based upon the precision

Assignment Help Programming Languages
Reference no: EM132211477

Question: Write a program rootTable.cpp which reads in the number of roots, a value increment and a precision and outputs a table of roots x^1/2; x^1/3;.....for the given number of roots and values of x equal to i times the increment up to and including 100.

For instance, if the number of roots is 10, and the precision is 2 and the increment is 10, then the table should be:

Value x^1/2 x^1/3 x^1/4 x^1/5 x^1/6 x^1/7 x^1/8 x^1/9 x^1/10 x^1/11

10 3.16 2.15 1.78 1.58 1.47 1.39 1.33 1.29 1.26 1.23

20 4.47 2.71 2.11 1.82 1.65 1.53 1.45 1.39 1.35 1.31

30 5.48 3.11 2.34 1.97 1.76 1.63 1.53 1.46 1.41 1.36

40 6.32 3.42 2.51 2.09 1.85 1.69 1.59 1.51 1.45 1.40

50 7.07 3.68 2.66 2.19 1.92 1.75 1.63 1.54 1.48 1.43

60 7.75 3.91 2.78 2.27 1.98 1.79 1.67 1.58 1.51 1.45

70 8.37 4.12 2.89 2.34 2.03 1.83 1.70 1.60 1.53 1.47

80 8.94 4.31 2.99 2.40 2.08 1.87 1.73 1.63 1.55 1.49

90 9.49 4.48 3.08 2.46 2.12 1.90 1.76 1.65 1.57 1.51

100 10.00 4.64 3.16 2.51 2.15 1.93 1.78 1.67 1.58 1.52

1. Prompt and read in the number of roots. Store the number as an integer.

2. Prompt and read in the value increment. Store the number as an integer.

3. Prompt and read in the precision. Store the number as an integer.

4. Compute the width of each column based upon the precision. All columns after the rst should have the same width. All columns should be separated by a blank space. Note that you need a minimum column width to properly display the column headers. However, for greater precision, your column width should increase with the precision.

5. Write a header row for the table. Use the column width to correctly adjust the column headers. Note that you will have to handle columns headers x^1/i dierently when i is a single digit (i < 10) or when i is two digits (i <= 10). You may assume that i has at most two digits.

Note: The last character in each root title column must be aligned with the last character in each decimal column. Just like shown in your picture. And no matter the variable, there should be 3 spaces between each column of decimals.

6. Write the rows of the table. The rst column is x. The i'th column is the value of x1=i. Use xed precision and the given number of digits after the decimal point specied by the precision. The decimal points in each column should line up.

Reference no: EM132211477

Questions Cloud

Write a program to simulate managing les on disk : Write a program to simulate managing les on disk. De ne the disk as a onedimensional array disk of size numOfSectors*sizeOfSector, where sizeOfSector indicates.
Write a program to read the salary for ten employees : Write a program to read the Salary for 10 employees. Calculate average of Salary. Calculate the Max Salary and Min Salary.
Discuss ethics in research : Discuss Ethics in Research - you need to be concerned about protection for those participants. As seen in 45 CFR 46 in the Code of Federal Regulations
Calculate area of a circle and of a rectangle : Write a program that uses two functions to calculate area of a circle and of a rectangle. Instruction: Declare P1 as a global constant.
Compute the width of each column based upon the precision : Compute the width of each column based upon the precision. All columns after the rst should have the same width. All columns should be separated by a blank.
Write a program that takes a shift value and a plaintext : Write a program that takes a shift value between +/- 26 and a plaintext message (no spaces) and returns the corresponding ciphertext.
Write a program that will simulate scheduling algorithms : Write a program that will simulate non - preemptive process scheduling algorithms in C++: FCFS(First Come First Serve).
Write a program that takes a single number from the user : Write a program that takes a single number from the user and returns the number multiplied by the number+7.
Write a program for alphabetic characters : Write a program that requests the user to enter an alphabetic character. Then convert the character from upper case to lower case or lower case to upper case.

Reviews

Write a Review

Programming Languages Questions & Answers

  Define the tolerance and the number of iterations

Write a function namedaxb1 group#.mthat takes the matrix of coefficients Aand the vector?bas input and returns the solution vector?xas an output.

  Solve the programming problem

Solve the programming problem

  Display the software developers data on the console

Meets specifications by demonstrating file handling, array data structure manipulation, and console output mastery by accomplishing the following.

  An sql query that will display all of the database fields.

An SQL database containing the fields in the current Chart of Accounts, plus a "balance" field.

  Probability line is executed in nth iteration of for loop

What is the probability that line is executed during the nth iteration of the for loop? What is the exact expected number of executions of line?

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Write a mortgage calculator in perl

The following formula is used to calculate the fixed monthly payment (P) required to fully amortize a loan of L dollars over a term of n months at a monthly interest rate of c. [If the quoted rate is 6%, for example, c is .06/12 or .005].

  Write a program to operate the barriers

The entrance to the car park is on the left hand side. When a car drives into the car park there is a sensor that detects the car and this should cause the barrier to be opened to allow the car in.

  Program where the computer plays against a human opponent

Write a function playExpert(marbles) that given a number of marbles returns the number of marbles that the computer will take following the expert mode rules.

  What flash and html5 can and cannot do

Provide recommendations for developers ­in terms of developing within and between each platform.

  Write a program that stores an array of five int values

Write a program that stores an array of 5 int values (not Integer), a Date object, and the double value 12.8 into a file named "Assign8_Q1.dat".

  Write program which computes amount of money earn

Write a program which computes amount of money person would earn over period of time if his or her salary is one penny the first day, two pennies the second day.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd