I'm trying to my friend with an assignment to turn a number from Fahrenheit to Celsius and Kalvin. All that works fine and good. The problem is that his professor wants him to "The main() function ought to use a loop to allow the user to enter a temperature repeatedly, stopping when a q or other non-numeric value is entered." as said in the directions. We're having trouble figuring out how to do this. I tried using the isdigit() function but haven't got it to work correctly. If someone could help that would be great. Thank you.
// hello.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include "stdafx.h"
#include <conio.h>
#include <ctype.h>
void Temperatures(double f);
int _tmain(int argc, _TCHAR* argv[])
{
{
float f;
while(isdigit(f)== true)
{
printf("Please enter a Fahrenheit temperature: ");
scanf("%f", &f);
Temperatures((double) f);
}
return 0;
}
}
void Temperatures(double f)
{
float Celcius;
float Kelvin;
Celcius=(f-32)/1.8;
Kelvin=Celcius+273.16;
printf("%ld", f);
printf("The temperature in Fahrenheit is %.2f degrees.\n", f);
printf("The temperature in Celcius is %.2f degrees.\n", Celcius);
printf("The temperature in Kelvin is %.2f degrees.\n", Kelvin);
}