Dev C++ Fahrenheit To Celsius

I am curious if it would ever be in good practice to omit constructor definitions from a class. Here, the intention of the Temperature class is to simply convert between one temperature scale to an.

Here is what I have so far. I understand the middle portion of it. I'm just having a hard time understanding which variables to stick in the voids.

  • 4 Contributors
  • forum 4 Replies
  • 681 Views
  • 8 Months Discussion Span
  • commentLatest Postby Andreas5Latest Post

Recommended Answers

Dev C++ Fahrenheit To Celsius Conversion

[QUOTE=vinochick;1056620]Here is what I have so far. I understand the middle portion of it. I'm just having a hard time understanding which variables to stick in the voids.

[CODE]#include

using namespace std;

//function prototypes
void getFahrenheit();
void calcCelsius();
void displayCelsius();

int main()
{
//declare variables
int …

Jump to Post

All 4 Replies

Fbody682

Here is what I have so far. I understand the middle portion of it. I'm just having a hard time understanding which variables to stick in the voids.

What are you getting from fahrenheit()? Put it in there as a reference argument/parameter...

Same with calcCelsius(), except you will need 2 arguments/parameters. One will have to be a reference, the other can be a value pass or a reference, it doesn't really matter. I'll leave it to you to decide which is which.

For displayCelsius() all that you have to do is send the celsius value. You don't need a reference because you aren't trying to modify it.

Simple C++ program to convert temperature from either Fahrenheit to Celsius or vise-versa.
C++
tempCon.cpp
/*******************************************************************
* C++ program to convert temperature from either Fahrenheit to *
* Celsius or vise-versa. *
* *
*******************************************************************/
#include<iostream>
#include<cctype>
usingnamespacestd;
intmain()
{
int temp, tempCon;
char unit;
cout << 'Please enter the temperature and measurement system (c or f): ';
cin >> temp;
cin >> unit;
if ( isupper(unit) )
{
unit = tolower(unit);
}
if (unit 'f')
{
temp = (temp - 32) / 9.0 * 5.0;
cout << temp << ' degrees Celsiusn';
}
elseif (unit 'c')
{
temp = 9.0 / 5.0 * temp + 32;
cout << temp << ' degrees Fahrenheitn';
}
else
{
cout << 'Sorry that unit of measure isn't recognized around here.n';
}
return0;
}

commented Mar 13, 2016

What is the line by line explanation of the above code please

Fahrenheit To Celsius C Programming

commented Mar 3, 2017

gumagana po ba nyan ?

commented Mar 7, 2019

:(

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment