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.*********
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...
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...
3. Write a C++ program that takes in the name of a store, and the following...
3. Write a C++ program that takes in the name of a store, and the following details for 4 employees working at the store; their first name, last name, number of hours they worked that week and how much they are paid per hour. Your program should output the name of the store, along with each employee's full name and how much they earned that week in the manner below. Monetary values should be format to 2 decimal places. Also...
Program in C Write a function that takes a string as an argument and removes the...
Program in C Write a function that takes a string as an argument and removes the spaces from the string.
Write a program in C or C++ that takes a number series of size n (n...
Write a program in C or C++ that takes a number series of size n (n integers) as input from the user, push all the numbers to the stack, and reverse the stack using recursion. Please note that this is not simply popping and printing the numbers, but the program should manipulate the stack to have the numbers stored in reverse order. In addition to the provided header file, the students can use the following function to print the content...
Write a C++ program that creates a file called Readings.txt. Inside the file, your program must...
Write a C++ program that creates a file called Readings.txt. Inside the file, your program must create a list. The list is composed of integer double pairs. There is one pair per line. The integers are in sequence (0, 1, 2, 3, ...) beginning with zero and ending with some random value between 512 and 1024. The doubles should be random values between 50.000 and 90.000. The doubles only have 3 decimal places. The file should look like this (of...
Write a program to draw a Pentagon with blue color inside a window. Using C ++...
Write a program to draw a Pentagon with blue color inside a window. Using C ++ with Output.
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT