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

C++ Write a program that finds the temperature, as an integer , that is the same

ID: 3795919 • Letter: C

Question

C++

Write a program that finds the temperature, as an integer , that is the same in both Celsius and Fahrenheit. The formula to convert from Celsius to Fahrenheit is: Fahrenheit = 32 + (nine fifths) times Celsius.


Your program should create two integer  variables for the temperature in Celsius and Fahrenheit.  Initialize the temperature to 100 degrees Celsius. In a loop, decrement the Celsius value and compute the corresponding temperature in Fahrenheit until the two values are the same.

Output should be:

The temperature is the same at -40

Explanation / Answer

/* C++ Program with proper comments that finds the temperature, as an integer , that is the same in both Celsius and Fahrenheit. */ #include using namespace std; /*When we don't use the std namespace, the computer will try to call cout or cin as if it weren't defined in a namespace (as most functions in our codes). Since it doesn't exist there, the computer tries to call something that doesn't exist! Hence, an error occurs.*/ int toFahrenheit( int celsius ) { return ( ( 9.0 / 5 ) * celsius + 32 ); //returning the value of temp converted from C to F } int main() { int celsius; //temp variable in celsius int fahrenheit; //temp variable in Fahrenheit celsius = 100; while ( ( fahrenheit = toFahrenheit( celsius ) ) != celsius ) { celsius--; //keep decrementing celsius value until both values become equal } cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote