Question: Purpose: The project is designed to ensure that the student know how to write and call functions. Problem: Write a program to take a depth
Purpose: The project is designed to ensure that the student know how to write and call functions.
Problem:
Write a program to take a depth (in Kilometers) inside the earth as input data; compute and display the temperature at this depth in degees Celsius and degree Fahrenheit. The relevant formulas are: celcius = 10*depth + 20 (Celsius temperatures are depth in km) fahrenheit = 1.8*clesius +32. You should include four functions in the program.
1. void print_introduction (void)
//prints out information to tell the user what this program does.
2. double_celsius_at_depth (double depth)
//compute and returns the celsius temperature at a depth measured in kilometers.
3. double celsius_to_fahrenheit (double celsius)
//converts a Celsius temperature celsius to Fahrenheit
4. void print_conclusions(double depth)
//display the conclusion that what is temperature in Fahrenheit at depth of the earth
Requirement: There is no calculation in main function except function calls to two void functions. The pseudo code for main function is follows:
Step 1: print introduction by calling print_conclusion function
Step 2: ask user to enter the depth
Step 3: get user's input
Step 4: print out the conclusion by calling print_conclusion function
Step 5: ask user if he/she wants to conintue
Step 6: get user's input
Step 7: repeat step 1 to 6 if user picks 'Y' or 'y'
Step 8: stop program
All the necessary calcuations are done in print_conclustion function. i.e. celsius_at_depth and clesius_to_fahrenheit functions are called from print_conclusion function. There is no explicit calculation in main function. No calling to two calculation functions in main function. Run the demo to see the sample output.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
