int main(void) { double fFeh; printf("Input temperature based on fahrenheit: "); scanf("%lf", &fFeh); printf("%.2lfF is %.2lfC, %.lfK", fFeh, Temperatures(fFeh).Celsius, Temperatures(fFeh).Kelvin); }
Temperatures get_temperatures(BufferedIO& buffered_io) throw(boost::system::system_error,BufferedIO::TimeoutException) { buffered_io.write("t"); const std::string line = strip_carriage_return(buffered_io.readStringUntil(boost::posix_time::seconds(1),"\n")); Json::Value reply; if(line.length() <= 2 || line[0] != 'T' || !Json::Reader().parse(line.substr(2), reply)) { return Temperatures(); } return Temperatures(reply); }
int main(void) { double input; if(scanf("%lf",&input)); printf("%.2f",Temperatures(input)); return 0; }
int main(void){ printf("This program transfer degrees Fahrenheit to Celsius and Kelvin.\n"); printf("Enter degrees Fahrenheit: "); while(scanf("%lf", &Fahren) == 1){ Temperatures(Fahren); printf("Enter degrees Fahrenheit (q to quit): "); } return 0; }
int main(void) { double Fahrenheit; printf("Please input the Fahrenheit:"); while(scanf("%lf", &Fahrenheit) == 1) //scanf的返回值代表成功输入的变量的数目,非数字不会被成功输入 { Temperatures(Fahrenheit); printf("Please input the Fahrenheit:"); } printf("end\n"); return 0; }
int main(void) { double fahr; printf("This program converts fahrenheit to celsius and kelvin.\n"); printf("Enter a temperature in degrees fahrenheit (q to quit): "); while (scanf("%lf", &fahr) == 1) // continue executing loop if user enters valid number { Temperatures(fahr); // convert fahr to celsius and kelvin // prompt for new input printf("Enter a temperature in degrees fahrenheit (q to quit): "); } printf("bye\n"); }
int main(void) { printf("This program converts a given temperature from " "Fahrenheit scale to Celsius and Absolute scale.\n"); printf("Please enter temperature to convert in Fahrenheit:\n"); double F; while(scanf("%lf", &F) == 1) { Temperatures(F); printf("Do you want to convert any more temperatures?" "(Please enter temperature or q to quit)\n:"); } details(); return 0; }