Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

**This is for the C Language. Trigonometric Calculator Specification You are required to write a program that calculates and displays values of the trigonometric functions

**This is for the C Language.

Trigonometric Calculator

Specification

You are required to write a program that calculates and displays values of the trigonometric functions sine, cosine, and tangent for user-supplied angular values. The basic program must comply with the following specification.

1. When the program is run, it is to display a short welcome message.

TRIG: the trigonometric calculator 

2. The program shall display a message prompting the user to enter input from the keyboard.

Please input request (h-help, q-quit): 

3. The following help message shall be displayed whenever the user types the letter h at the input prompt.

The input format is a single line of letters and numbers comprising the following fields: These fields must be input in the order shown above, where is a set of letters, and the others are single numbers defining the range of computation. The field consists of zero or more of the letters from the set , which indicate respectively, (1) The desired trig functions: sin, tan, cos. (2) Whether to use degrees or radians for input parameters. (3) Whether to quit the program. Example input: scr 0 2.3 3 

4. The program shall exit if the user types the letter q at the input prompt.

5. The user may enter a single line of input composed of four fields separated by whitespace,

 

where the angle brackets < > indicate particular information fields as described below.

6. The field shall be zero or more of the letters stcdr, indicating sine (s), tangent (t), cosine (c), degrees (d), or radians (r) to indicate trigonometric function types and input units.

7. The field shall be followed by three numerical values that indicate, in order, the starting value for the calculations, the final value for the calculations and the number of intermediate rows in the table. The first two values are floating point, the third is an integer.

8. The following defaults shall be implemented when all or part of the field is missing:

(a) If no function type is specified, all 3 trigonometric functions shall be displayed.

(b) If no unit type is specified, units of entry shall default to degrees.

9. The program shall respond to all inputs in a case insensitive manner. i.e. any letters are valid in both upper and lower case.

10. The program shall validate user input, and recover gracefully from illegal input. Since a user might enter any arbitrary string of characters, many different errors are possible, including:

Specifying both d and r in the field.

Entering invalid letters in the field.

Entering letters or symbols instead of numbers in any of the last three fields.

Failing to enter exactly three numerical values after the field.

Entering a negative or non-integer value for the number of intermediate rows.

11. On detection of illegal input, the following error message shall be displayed:

Error: Illegal input! 

12. The results shall be displayed in a tabular format, with the first column containing the angle values in degrees, the second column containing the angle values in radians and the next columns containing the values of the requested trigonometric functions. The values in each row shall be space delimited, with columns 10 characters wide and right justified. Values in the table shall be displayed to 3 decimal places. Undefined values shall be represented with the string "N/A".

13. The first row of the table shall display headings describing the contents of the columns.

 Degrees Radians Sin Cos Tan 

The headings for degrees and radians shall always be shown, but those for sin, cos and tan are only displayed if the functions are selected. There shall be a blank line after the header row.

14. After displaying the tabular output or an error message, the program shall return to the input prompt (see Item 2 above).

Example Output

TRIG: the trigonometric calculator Please input request (h-help, q-quit): scr 0 2.3 3 Degrees Radians Sin Cos 0.000 0.000 0.000 1.000 32.945 0.575 0.544 0.839 65.890 1.150 0.913 0.408 98.835 1.725 0.988 -0.154 131.780 2.300 0.746 -0.666 Please input request (h-help, q-quit): q 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions