Question: Write a C++ program which uses an array of numbers to store pre-calculated values of the sine function of certain values, and can then display

Write a C++ program which uses an array of numbers to store pre-calculated values of the sine function of certain values, and can then display values of various different formulas futher calculated from the stored values.

- The main function of your program must contain an array called sine_value of 20 elements of type double:

-- Use a constant called SIZE (set to the value 20) for the size of this array, and throughout the rest of program wherever the array size is needed, obtain it through this constant and not the literal number 20.

--The values of the array elements must be set to the sine of their index, e.g. sine_value[0] must be sin(0), sine_value[1] must be sin(1), etc. Setting these values must be done in a function with teh prototype:

void fill_array(double array[]);

The fill_array function must be called once at the beginning of the program.

- The program must display a menu of choices to the user, acccept their selection from the menu and respond to it, then display the menu again, until the user chooses to quit.

- The valid menu choices are the numbers 1,2,3 and 4. If the user enters an invalid integer, the menu must be redisplayed. The program is only required to work if the menu choices is an integer.

- If the user chooses a formula from the menu, they must be prompted fro the values a and/or b contained in the formula, and then a table displayed showing the calculated values of the resulting formula:

-- Get the final values of the formula using the pre-calculated values contained in the sine_values array- don't call the function sin again in this part of the program.

-- For the values of a and b, the user may enter numbers with our without a fractional part.

-- Numbers with fractions must be displayed with 3 places after the decimal point, and columns of numbers must be right-aligned, as show in the sample run below.

- Besides the fill_array funtion which is required, you may use other funtions of your own design to organize your program if you like.

- Use comments to show the main steps in the program, and to document variable declarations.

- A sample run of your program should look like:

Write a C++ program which uses an array of numbers to store

pre-calculated values of the sine function of certain values, and can then

display values of various different formulas futher calculated from the stored values.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!