Complete all the functions in this program: /Description: This program prompts t
ID: 670985 • Letter: C
Question
Complete all the functions in this program:
/Description: This program prompts the user to input either C or F.
// If F is input, program prompts for a Farenheit temp,
// calculates and prints the Celcius equivalent.
// If C is input, program prompts for a Celsius temp,
// calculates and prints the Farenheit equivalent.
// Prints an appropriate message depending on the temperature
//*********************************************************************
#include <iostream>
#include <iomanip>
using namespace std ;
// function prototypes
double toCelcius(double f_temp);
double toFarenhet (double c_temp) ;
char getChoice();
bool isCold( double temp, char scale );
bool isHot(double temp ,char scale );
void process_celcius ();
void process_farenheit ();
void programmer_info();
//global constants
const double FARENHEIT_FREEZE = 32.0;
const double FARENHEIT_BOIL = 212.0;
const double CELSIUS_FREEZE = 0.0;
const double CELSIUS_BOIL = 100.0;
int main()
{
// local variable declarations for main
char choice; // to choose Celsius or Farenheit
choice = getChoice();
cout << "choice is " << choice <<endl;
if (choice == 'C')
process_celcius ();
else // choice is 'F'
process_farenheit ();
cout << " ********************** ";
programmer_info();
return(0);
}
///=========endOFmain==================
char getChoice()
{
//prompt for an indication of temperature scale
// return 'C' for celsius
// return 'F' for farenheit
// loop until user inputs C or F.
return 'x';
}
///====================================
void programmer_info()
{
// prints out required information
// about the programmer(s)
cout << "It's me! ";
}
///====================================
void process_celcius ()
{
// prompt for a Celcius temp
// call function toFarenhet to convert the input temperature to Farenheit
// print out Farenheit equivalent
// Prints out "is HOT", "is COLD", or "HUMDRUM"
// calls functions isHot and isCold
cout << "process_celsius " << endl;
}
///====================================
void process_farenheit ()
{
// prompt for a Farenheit temp
// print out Celcius equivalent
// Prints out "is HOT", "is COLD", or "HUMDRUM"
// calls functions isHot and isCold
cout << "process_farenheit " << endl;
}
///====================================
bool isHot(double temp ,char scale )
{
// If the parameter temp is at or above boiling,
// the function returns true
// otherwise it returns false
// scale is either 'F' (farenhiet) or 'C' (Celsius)
return false;
}
///====================================
bool isCold( double temp, char scale )
{
// If the parameter temp is at or below freezing,
// the function returns true
// otherwise it returns false
// scale is either 'F' (farenhiet) or 'C' (Celsius)
return true;
}
///====================================
double toCelcius(double f_temp)
{
//C = ( 5/9 ) (F -32 )
return 1.0;
}
///====================================
double toFarenhet (double c_temp)
{
// F = ( 9/5 ) * C + 32
return 0.0;
}
///====================================
Explanation / Answer
/*Complete all the functions in this program:
//Description: This program prompts the user to input either C or F.
// If F is input, program prompts for a Farenheit temp,
// calculates and prints the Celcius equivalent.
// If C is input, program prompts for a Celsius temp,
// calculates and prints the Farenheit equivalent.
// Prints an appropriate message depending on the temperature
*/
#include <iostream>
#include <iomanip>
using namespace std ;
// function prototypes
double toCelcius(double f_temp);
double toFarenhet (double c_temp) ;
char getChoice();
bool isCold( double temp, char scale );
bool isHot(double temp ,char scale );
void process_celcius ();
void process_farenheit ();
void programmer_info();
//global constants
const double FARENHEIT_FREEZE = 32.0;
const double FARENHEIT_BOIL = 212.0;
const double CELSIUS_FREEZE = 0.0;
const double CELSIUS_BOIL = 100.0;
int main()
{
string choice;
choice = getChoice();
cout << "Choice is: " << choice <<endl;
if (choice == "C")
{
process_celcius();
}
else if (choice=="F")// choice is 'F'
{
process_farenheit();
}
else()
{
cout << "Enter either C or F ";
}
programmer_info();
return(0);
}
char getChoice()
{
string User_Choice;
cout << "Enter temperature Scale: Press 'C' for Celcius and 'F' for Faranheit. ";
cin >> User_Choice;
//prompt for an indication of temperature scale
// return 'C' for celsius
// return 'F' for farenheit
// loop until user inputs C or F.
return User_Choice;
}
void programmer_info()
{
// prints out required information
// about the programmer(s)
cout << "It's me! ";
}
void process_celcius ()
{
double v_UserChoice_Cel,v_output_ToFar;
string scale;
scale=="F";
cout << "Enter the value in Celcius: ";
cin >> v_UserChoice_Cel;
v_output_ToFar = toFarenhet(v_UserChoice_Cel);
cout << "The Farenheit equalent is:"<<v_output_ToFar<<endl;
if (isHot(v_output_ToFar,scale)== true)
{
cout << "Its HOT "<<endl;
}
else if (isCold(v_output_ToFar,scale)==true)
{
cout << "Its COLD "<<endl;
}
else if((v_output_ToFar,scale)== false)&&(isCold(v_output_ToFar,scale)==false)
{
cout << "Its HUMDRUM "<<endl;
}
// prompt for a Celcius temp
// call function toFarenhet to convert the input temperature to Farenheit
// print out Farenheit equivalent
// Prints out "is HOT", "is COLD", or "HUMDRUM"
// calls functions isHot and isCold
//cout << "process_celsius " << endl;
}
void process_farenheit ()
{
double v_UserChoice_Far,v_output_ToCel;
string scale = "C";
cout << "Enter the value in Farenheit: ";
cin >> v_UserChoice_Far;
v_output_ToCel = toCelcius(v_UserChoice_Far);
cout << "The Celcius equalent is:"<<v_output_ToCel<<endl;
if (isHot(v_output_ToCel,scale)== true)
{
cout << "Its HOT "<<endl;
}
else if (isCold(v_output_ToCel,scale)==true)
{
cout << "Its COLD "<<endl;
}
else if((v_output_ToCel,scale)== false)&&(isCold(v_output_ToCel,scale)==false)
{
cout << "Its HUMDRUM "<<endl;
}
// prompt for a Farenheit temp
// print out Celcius equivalent
// Prints out "is HOT", "is COLD", or "HUMDRUM"
// calls functions isHot and isCold
// cout << "process_farenheit " << endl;
}
bool isHot(double temp ,string scale )
{
if (scale=="C" && temp>=CELSIUS_BOIL ||scale=="F" && temp>=FARENHEIT_BOIL)
{
return true;
}
else()
{
return false;
}
// If the parameter temp is at or above boiling,
// the function returns true
// otherwise it returns false
// scale is either 'F' (farenhiet) or 'C' (Celsius)
//return false;
}
bool isCold( double temp, string scale )
{
if (scale=="C" && temp <=CELSIUS_FREEZE) ||(scale=="F")&&temp<=FARENHEIT_FREEZE)
{
return true;
}
else()
{
return false;
}
else()
{
}
// If the parameter temp is at or below freezing,
// the function returns true
// otherwise it returns false
// scale is either 'F' (farenhiet) or 'C' (Celsius)
// return true;
}
double toCelcius(double f_temp)
{
//C = ( 5/9 ) (F -32 )
double c_temp;
c_temp=(f_temp-32);
c_temp=((c_temp*5)/9);
return c_temp;
}
double toFarenhet (double c_temp)
{
double f_temp;
f_temp= ((c_temp*9)/5);
f_temp= (c_temp+32);
return f_temp;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.