Answered step by step
Verified Expert Solution
Question
1 Approved Answer
USE Setw(#) to make columns. Write a program logTable.cpp that displays a table of log values computed in base 10 from two starting values: base
USE Setw(#) to make columns.
Write a program logTable.cpp that displays a table of log values computed in base 10 from two starting values: base a and value b. The rows of the table correspond to changing values of a by 1. The columns of the table correspond to changing values of b by 1. The program will read in the starting value for base a, how many rows of the table, starting value for b, and how many columns of the table. In the table entries, you will compute the function logy x in base 10 for combinations ofy and x, where y = a , x = b A, and 0 1s an offset value. To do this, you will use the base conversion equation for logarithms: log, x = log10 log10 V For instance, if the user inputs 3 for starting base a, 10 rows, 7 for starting value b, 5 columns, and a precision of 2, then the table will display as: Table starts at logarithm of b = 7 with base a = 3 Log values b+ 0 b+1 b2 b+ 3 b+ 4 a 0 1.771.89 2.00 2.10 2.18 a11.40 1.50 1.58 1.66 1.73 a 21.21 1.291.371.43 1.49 a + 31.09 1.16 1.23 1.29 1.34 a 41.00 1.07 1.13 1.18 1.23 a 50.94 1.00 1.06 1.11 1.15 a60.89 0.951.00 1.05 1.09 a+ 70.85 0.90 0.95 1.00 1.04 a + 80.81 0.870.92 0.96 1.00 a+ 90.780.84 0.88 0.93 0.96 Thus, for starting values a-3 and b = 7, the top left entry is calculated as log,7 = log 1.7712437492, but is displayed as 1.77 due to a precision of 2. The entry below this one computes log4 7 and the one to the right computes log3 8. All other entries in the table are similarly computed using incremented combinations of starting values a and b across the rows and columns of the table. log10 3 1. 2. 3. 4. 5. 6. Prompt and read in the starting base value a. Store the number as an integer. Prompt and read in the number of rows of the table. Store the number as an integer. Prompt and read in the starting value b. Store the number as an integer. Prompt and read in the number of columns of the table. Store the number as an integer. Prompt and read in the precision. Store the number as an integer. Assume that the input values in steps 1-4 will be in the range 0 -99. You do not need to error check for this 7. Formatting the table. All columns after the first should have the same width. Use four plus the precision to set the column width. Though, ensure that the minimum column width is 6 characters. All columns should be separated by a single blank space. However, for greater precision, your column width should increase with the precision. The first column (leftmost) should have a column width of 10 Format the entries in the first column (leftmost) to appear to the right in the column. You will have to handle when is a single digit (Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started