Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

THIS IS C++ Write a program to take a depth (in kilometers) inside the earth as

ID: 3850423 • Letter: T

Question

THIS IS C++

Write a program to take a depth (in kilometers) inside the earth as input data; compute and display the temperature at this depth in degrees Celsius and degree Fahrenheit. The relevant formulas are: celsius = 10*depth + 20 (Celsius temperature at depth in km) fahrenheit = 1.8*celsius + 32. You should include four functions in your program.

1. void print_introduction (void)
// 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 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_introduction 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 continue Step 6: get user’s input
Step 7: repeat step 1 to step 6 if user picks ‘Y’ or ‘y’ Step 8: Stop program

All the necessary calculations are done in print_conclusion function. i.e. celsius_at depth and celsius_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 the see the sample output

THIS IS C++

Hello! The program wiu tell you the temperature of the earth at any depth. Enter a depth in KM 10 The temptature 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 temptature 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:

Explanation / Answer

#include<stdio.h>

/*Function Declaration*/
doublecelsiusAtDepth;
doublecelsiusToFahrenheit;
voidprintResults;

intmain()
{
   doubledepth;
   printf("Entera depth value:");
   scanf("%lf",&depth);
   
   doublecelsius=celsuisAtDepth;
   doublefahrenheit=celsiusToFahrenheit(celsius);
   PrintResults(celsius,fahrenheit);
   
   return(0);
}
/*Celsius=10*depth=20*/
doublecelsiusAtDepth (doubledepth)
{
   return(10*depth+20);
}
/*Fahrenheit=((18.0/10.0)*celsius+32)*/
doublecelsiusToFahrenheit (doublecelsius)
{
   return((18.0/10.0)*celsius+32);
}
/*FunctionprintResults should take in the two temperatures and print them.*/
void printResults(double celsius,doublefahrenheit)
{
   printf("Celsius:%lf Fahrenheit: %lf ", celsius, fahrenheit);

}