Write a program in C++ that gives the temperature of earth at a depth. It must be in C++ and follow the information below:
Problem description
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 celcius +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 user’s input
4. print out the conclusion by calling
print_conclusion function
5. ask user if he/she wants to continue
6. get user’s 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.
The program run must look as follows:
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
#include <iostream>
using namespace std;
//printing introduction function
void print_introduction(){
cout<<"Hello! The program will tell you the temperature of the earth at any depth."<<endl;
}
//Temperature calculation function
double celsius_at_depth(double depth){
return (10*depth)+20;
}
//Converting the celsius to fahrenheit function
double celsius_to_fahrenheit (double celsius){
return (1.8*celsius) +32;
}
//printing conclusion method that calls the above two methods
void print_conclusion(double depth){
cout<<"The temperature of the earth at a depth of "<<depth<< " is "<<celsius_at_depth(depth)<<" and "<< celsius_to_fahrenheit(celsius_at_depth(depth))<<" in Fahrenheit."<<endl;
}
int main() {
//using do while loop to run the program continously
char ch='y';
double depth=0;
do{
cout<<"Enter a depth in KM: ";
cin>>depth;
print_conclusion(depth);
cout<<"Would you like to do it again? (Y/N): ";
cin>>ch;
}while(ch=='y'|| ch=='Y');
return 0;
}
Output:
Write a program in C++ that gives the temperature of earth at a depth. It must...
Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom function c_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a value-returning...
FOR PYTHON Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom functionc_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a...
Write a program named FahrenheitToCelsius that accepts a temperature in Fahrenheit from a user and converts it to Celsius by subtracting 32 from the Fahrenheit value and multiplying the result by 5/9. Display both values to one decimal place. For example, if 88.5 degrees is input, the output would be: 88.5 F is 31.4 C Answer in C# (Posting incomplete code i have so far that wont run correctly.) using System; using static System.Console; class FahrenheitToCelsius { static void Main()...
You are to write a program IN C++ that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: if the an item's wholesale cost is 5.00 and its markup percentage is 100%, then the item's retail price is 10.00 If an item's wholesale cost is 5.00 and its markup percentage is 50%, then the item's retail price is 7.50 Program design specs. You should have 5...
Can you help me to create this program, please? Prompt the user for the user for a number of degrees in Fahrenheit as an int. That number should be passed to a function named ffocREFO. This function will do the necessary calculation to convert the passed temperature to degrees Celsius as a double. The function MUST have a void return type and have the following prototype: void ffccREF(double& celsius, int Faren); In your main, display both the entered temperature and...
Write a C++ program that prompts a user to enter a temperature in Fahrenheit as a real number. After the temperature is entered display the temperature in Celsius. Your program will then prompt the user if they want to continue. If the character n or N is entered the program will stop; otherwise, the program will continue. After your program stops accepting temperatures display the average of all the temperatures entered in both Fahrenheit and Celsius. Be sure to use...
Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom function c_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a value-returning...
Modular program mathlab: Write a program in Matlab that would continuously ask the user for an input between 1 and 6, which would represent the result of rolling a die. The program would then generate a random integer between 1 and 6 and compare its value to the value entered by user. If the user’s die is larger, it should display, “You got it” If the user’s die is smaller, it should display, “Nice try” If the results are the...
CAN YOU HELP ME TO DO THIS EXERCISE PLEASE USING C++ Write a program that gives the user two options: (1) Transform a temperature value from Celsius to Fahrenheit or (2) Transform a temperature value to Fahrenheit to Celsius. The two options are communicated to the user by the console by means of "cout" with this text: "If you want to transform from Fahrenheit to Celsius between character C (capital)." "If you want to transform from Celsius to Fahrenheit between...
Write a program in C that will convert all 12 months' average temperature from Celsius to Fahrenheit. You need to create an array named aye jump and prompt the user to input average temperature in Celsius for all 12 months. After that, you need to develop a user temperatures from Celsius to Fahrenheit and pass the array as reference and convert all temperatures from Celsius to Fahrenheit. Next, compute the average temperature of the year and assign it to a...