Answer to Question #301380 in C++ for junior

Question #301380
  • A) Create a function called To_Celsius that takes in a temperature in Fahrenheit temperature and returns the equivalent in Celsius.
  • B) Create another function called To_Fahrenheit that takes in a temperature in Celsius and returns the equivalent in Fahrenheit.
  • C) Use these functions to write a function called Print_EQ_Temps that prints out the Fahrenheit equivalents of all Celsius temperatures from 0°-100°, and the Celsius equivalents of all Fahrenheit temperatures from 32°-212°. Then, call this function in your program.


Hint: Use for loops to input into your functions.


1
Expert's answer
2022-02-23T06:24:43-0500


#include <iostream>
#include <cmath>
using namespace std;


double To_Celsius(double fahrenheit){
	return (fahrenheit - 32.0) * 5.0 / 9.0;
}


double To_Fahrenheit(double celsius){
	return celsius * 9.0 / 5.0 + 32.0;
}


void Print_EQ_Temps(){
	for(int i=0; i>=-100;i--){
		cout<<i<<"C = "<<To_Fahrenheit(i)<<"F\n";
	}
	cout<<"\n\n";
	for(int i=32; i>=-212;i--){
		cout<<i<<"F = "<<To_Celsius(i)<<"C\n";
	}
}


int main() {
	
	Print_EQ_Temps();


	system("pause");
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog