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

by using j edit Temperature Converter Version 1.0 This program will do following

ID: 3666528 • Letter: B

Question

by using j edit

Temperature Converter

Version 1.0

This program will do following:

1) It takes a Celsius temperature as input, converts the temperature to its Fahrenheit equivalent and output the result

2) It takes a Fahrenheit temperature as input, converts it to its Celsius equivalent and output the result. You need add code to do this part.

Put your name here: *************************************************************************/

#include <iostream>

using namespace std;

int main(){

double cTemp; // The entered Celsius temperature

double fTemp; // The calculated Fahrenheit temperature

// Prompt the user for a Celsius temp and read the value entered

cout << "Enter a Celsius temperature. -> ";

cin >> cTemp;

cout << endl << endl;

// Calculate the Fahrenheit equivalent

fTemp = (9.0 / 5.0) * cTemp + 32.0;

// Output the result

cout << cTemp << " degrees Celsius is equivalent to " << fTemp

<< " degrees Fahrenheit." << endl;

return 0; }

3. Compile your program with the following command.

g++ TempConverter.cpp –o TempConverter

4. Run your program with the command

./TempConverter

Copy the output and save it to a file, yourNameLab1Result.txt using jedit.

5. Modify your program by introducing two functions and test them:

double celsius2Fahrenheit(double c);

double fahrenheit2Celsius (double c);

6. Repeat step 4.

Explanation / Answer

#include<iostream>
using namespace std;
int main(){
   double cTemp; // The entered Celsius temperature
   double fTemp; // The calculated Fahrenheit temperature
   // Prompt the user for a Celsius temp and read the value entered
   cout << "Enter a Celsius temperature. -> ";
   cin >> cTemp;
   cout << endl << endl;
   // Calculate the Fahrenheit equivalent
   fTemp = (9.0 / 5.0) * cTemp + 32.0;
   // Output the