Question
The purpose of this assignment is to introduce you to basic C programming, including the use of functions, selections, and loops. For this program, you
The purpose of this assignment is to introduce you to basic C programming, including the use of functions, selections, and loops. For this program, you will communicate with the user asking whether to convert Fahrenheit into Celsius, or vice versa. Then, you call the corresponding function to do the conversion. Continue to do this until the user has decided not to use the system any more. You should write a sketch and implement the steps in detail one statement after another.
Instructions:
You may design your program with minor variations, but the following is a sample with key requirements (constants, functions, selections, and loops):
1. Your program starts with a while or do-while loop with the condition that your input character is F or C;
1) Before and within the while loop, it prints "your name > Fahrenheit/Celsius Converter. Please enter F or C:" For example, if it is my program, it will print: Jim Chen > Fahrenheit/Celsius Converter. Please enter F or C:
2) If you have any other input (other than F, f, C, or c), you inform the user that "The input is unknown!" and your program will quit the loop.
2. Within the loop, your program will use F, f, C, or c as selections in a switch statement. Actually, you can put "The input is unkown!" in the switch statement's default selection.
3. Within the corresponding switch selection, your program
1) prints "your name > Please enter a Fahrenheit degree number:" if you entered F or f; prints "your name > Please enter a Celsius degree number:" if you entered C or c.
2) reads the input number, which should be a "double" and should be passed as a parameter into the following corresponding function.
3) in case of F or f, call a function "double fc_converter(double);" with the input value; in case of C or c, call a function "double cf_converter(double);" otherwise, you inform the user "The input is unknown!" in the default selection.
4. In "double fc_converter(double);" you should use "if" to do the following.
1) if you enter a number in the range of -200 to +200, for example, "32", it will calculate according to the equation: C = FCR*(F - 32.00), where FCR is a pre-defined constant 0.556. Your variable should be in "double". After that, it will print the following before returning the Celsius degree:
32.00 F ==> 0.00 C
2) otherwise, it will print "Invalid Celsius temperature." and return a value according to the equation: C = sqrt(F).
5. Similarly, in "double cf_converter(double);" you should use "if" to do the following.
1) if you enter a number in the range of -200 to + 200, for example, "0", it will calculate according to the equation: F = CFR*C + 32.00, where CFR is a defined constant 1.8. After that, it will print the following before returning the Fahrenheit degree:
0.00 C ==> 32.00 F
2) otherwise, it will print "Invalid Fahrenheit temperature." and return a value according to the equation F = pow(C, 3).
6. After the switch, if your input is F, f, C, or c at the beginning,
1) print out the return value as: "The calculated value from the converter function is:
2) Loop back to Step 1.
7. For any other input at the beginning, your program exits the loop, and the program finishes.
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