Question

In: Computer Science

write c++ program that takes the depth ( in kilometer) inside the earth to compute and...

write c++ program that takes the depth ( in kilometer) inside the earth to compute and display the temperature at the depth in degrees celsius and fahrenheit. the relevant formulas are:

celsius+ 10 x depth + 20

fahrenheit = 9/5 celsius + 23

Solutions

Expert Solution

Answer:

The given formulae in the question are wrong the actual formula to convert depth into

Celsius =10 * depth + 20

Fahrenheit= 9/5 * Celsius+ 32

Here I am providing the c++ code as per your requirements

Raw code:

#include <iostream>

//including input output streams

using namespace std;

//using namespace standard

int main()

//main

{

float depth; //declairing variable for depth of datatype as float

float cel,fahr;//declairing variable for celsius and Fahrenheit

cout<<"Please enter the depth(Kilometers):"; //prompting the user

cin>>depth; //taking the depth input

cel= 10.0*depth+20.0; //formula to convert into celsius

fahr=(9.0/5.0)*(cel)+32.0;//formula to convert to Fahrenheit

cout<<"Celsius:"<<cel<<endl;//printing the celsius degrees

cout<<"Fahrenheit:"<<fahr<<endl;//printing the Fahrenheit degrees

return 0;

}

Code in the editor:

output:

Please feel free to comment in the comment section if you have any doubts or queries

Thank you!

Note: if you want to code as per the formula you have provided, please change 12 and 13 lines in the code editor.

Hoppe this helps!


Related Solutions

Program in C++ **********Write a program to compute the number of collisions required in a long...
Program in C++ **********Write a program to compute the number of collisions required in a long random sequence of insertions using linear probing, quadratic probing and double hashing. For simplicity, only integers will be hashed and the hash function h(x) = x % D where D is the size of the table (fixed size of 1001). The simulation should continue until the quadratic hashing fails.*********
1. Write a program in C++ that takes as inputs a positiveinteger n and a...
1. Write a program in C++ that takes as inputs a positive integer n and a positive double a. The function should compute the geometric sum with base a up to the powern and stores the result as a protected variable. That is, the sum is: 1 + ? + ? ^2 + ? ^3 + ? ^4 + ⋯ + ? ^?2.  Write a program in C++ that takes as input a positive integer n and computes the following productsum...
in C++ Write a program to compute the current and the power dissipation in an AC...
in C++ Write a program to compute the current and the power dissipation in an AC circuit that has four resistors R1, R2, R3, and R4 in parallel. The voltage source is V. Test your solution with various voltage levels and resistor values. Execute and submit the program and the results in screen captures. Please note that the equivalent resistor is given by 1/Rtotal = 1/R1 + 1/R2 + 1/R3 + 1/R4 and the current I is given by I...
C program help 1. Write a program to compute the Mileage given by a vehicle. Mileage...
C program help 1. Write a program to compute the Mileage given by a vehicle. Mileage = (new_odometer – old_odometer)/(gallons_gas) // illustrating how ‘for’ loop works. 2. How to initialize an array of size 5 using an initializer list and to compute it’s sum How to initialize an array of size 5 with even numbers starting from 2 using ‘for’ loop and to compute it’s sum 3. Program to compute the car insurance premium for a person based on their...
C++ Write a program that takes a string and integer as input, and outputs a sentence...
C++ Write a program that takes a string and integer as input, and outputs a sentence using those items as below. The program repeats until the input string is "quit". If the input is: apples 5 shoes 2 quit 0 the output is: Eating 5 apples a day keeps your doctor away. Eating 2 shoes a day keeps your doctor away.
Write a program in C or in Java, that takes an integer value N from the...
Write a program in C or in Java, that takes an integer value N from the command line, generates N random points in the unit square, and computes the distance separating the closest pair of points. A unit square is a square with sides of length 1, at points (0, 0), (0, 1), (1, 0), and (1, 1). If you wish to avoid the command-line processing, you can just assume you will generate a fixed number of points, say between...
Write a program in Objective C that takes an integer keyed in from the terminal and...
Write a program in Objective C that takes an integer keyed in from the terminal and extracts and displays each digit of the integer in Eglish. So if the user types 647, the program should display the following: six four seven
Write a C++ program that takes in a set of daily average temperatures (up to a...
Write a C++ program that takes in a set of daily average temperatures (up to a maximum of 30): 1.Ask the user for a temperature 2.If the user enters a -1 then stop asking for temperatures. 3. After the user is done entering temperatures: a. Print out the temperatures entered. b. print out the average, high and low temperatures. To get average, use: average = (sum of temps) divided by (count of temps) to get max or min, either keep...
Write a C program that takes a double value and rounds it up or off using...
Write a C program that takes a double value and rounds it up or off using ternary expression in the program. Example, if -2.5 is inputted the value should give -3.0
Write a complete C++ program that prompts the user for and takes as input, numbers until...
Write a complete C++ program that prompts the user for and takes as input, numbers until the user types in a negative number. the program should add all of the numbers together. Then if the result is less than 20 the program should multiply the result by 3, otherwise subtract 2 from the result. Finally, the program should printout the result.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT