Question: I'm using C++ to write a program that converts from Fahrenheit to Celsius and vice versa, with the option of displaying the Kelvin temperature with
I'm using C++ to write a program that converts from Fahrenheit to Celsius and vice versa, with the option of displaying the Kelvin temperature with a Y/N message. When compiling, two error messages pop up saying function does not take 1 parameters in regards to the showDegreesK function. Can someone figure out what I need to do to fix this? My code I have so far is below. Please make sure the code compiles and the output looks something like this.
Welcome to the Temperature Converter!
Would you like to see degrees Kelvin (K) in the results? (Y/N): Y
Select conversion type (1=F to C, 2=C to F, 0=end): 1
Enter your Fahrenheit temperature: 32
A temp of 32 Fahrenheit converted to Celsius = 0 C.
This is also a temperature of: 273.15 K
Select conversion type (1=F to C, 2=C to F, 0=end): 2
Enter your Celsius temperature: 100
A temp of 100 Celsius converted to Fahrenheit = 212 F.
This is also a temperature of: 373.15 K
Select conversion type (1=F to C, 2=C to F, 0=end): 0
Thanks for using the temperature converter!
Here is the code I've written so far.
#include "stdafx.h" #includeusing namespace std; using namespace System; double FtoC(double t); double CtoF(double t); double showDegreesK(char kchoice, int, double); int main() { double temp, result; int choice; char kchoice; cout << "Welcome to the temp conversion program." << endl; do { cout << "Would you like to see degrees Kelvin (K) in the results? (Y/N): "; cin >> kchoice; cout << " Conversion Type (1=F to C, 2=C to F, 0=Quit: "; cin >> choice; if (choice == 1) { cout << "Enter your Fahrenheit temp: "; cin >> temp; result = FtoC(temp); cout << "A temp of " << temp << "F is equal to " << result << "C." << endl; showDegreesK(kchoice); } else if (choice == 2) { cout << "Enter your Celcius temp: "; cin >> temp; result = CtoF(temp); cout << "A temp of " << temp << "C is equal to " << result << "F." << endl; showDegreesK(kchoice); } } while (choice != 0); cout << " Thanks for using the temp converter!" << endl; system("Pause"); return 0; } double FtoC(double t) { double r; r = (5.0/9.0 * (t - 32.0)); return r; } double CtoF(double t) { double r; r = ((9.0 / 5.0) * t) + 32; return r; } double showDegreesK(char kchoice, int choice, double result) { double kresult; if (kchoice == 'Y' && choice == 1) { kresult = result + 273.15; } else if (kchoice == 'Y' && choice == 2) { kresult = (result + 459.67) * (5.0/9.0); } return kresult; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
