Question: THIS IS C++ PROGRAMMING: Before starting: Make sure that you understand the following things: - How to declare a function. - How to write a
THIS IS C++ PROGRAMMING:
Before starting: Make sure that you understand the following things:
- How to declare a function.
- How to write a function.
- How to call a function, including call function A from function B which is not main function.
QUESTION:
Write a program to take a depth in kilometers inside the earth as input data; calculate and display the temperature at this depth in both degrees Celsius and degree Fahrenheit. The formulas are:
-Celsius temperature at depth in km: celsius = 10 x depth(km) + 20
-Convert celsius to fahrenheit: fahrenheit = 1.8 x celsius + 32
You should have 4 functions in your program.
1.) void print_introduction (){} // prints out information to tell the user what this program does.
2.) double celsius_at_depth (double depth){} // computes 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_conclusion(double depth){} // display the conclusion that what is the temperature in both Celsius and Fahrenheit at depth of the earth
Additional Requirement:
There is no calculation in main function. The pseudo code steps for main function as follows:
1.) print introduction by calling print_introduction function
2.) ask user to enter the depth
3.) get users input
4.) print out the conclusion by calling print_conclusion function
5.) ask user if he/she wants to continue
6.) get users input
7.) repeat step 2 to step 6 if user picks Y or y
8.) Stop program
All the necessary calculations are done in print_conclusion function. celsius_at_depth and celsius_to_fahrenheit functions are called from print_conclusion function.
There is no calculation in main function. No calling celsius_at_depth or celsius_to_fahrenheit functions in main function.
SAMPLE RUN:
Hello! The program will tell you the temperature of the earth at any depth.
Enter a depth in KM: 10
The temperature of the earth at a depth of 10 KM is 120 in Celsius, and 248 in Fahrenheit.
Would you like to do it again? (Y/N): y
Enter a depth in KM: 20
The temperature of the earth at a depth of 20 KM is 220 in Celsius, and 428 in Fahrenheit.
Would you like to do it again? (Y/N): n
Program ended with exit code: 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
