The Kelvin temperature scale is very similar to the Celsius
The Kelvin temperature scale is very similar to the Celsius temperature scale, except that zero degrees Kelvin is absolute zero, the lowest physically conceivable temperature. Zero degrees Kelvin is -273.16 degrees Celsius.1 WRITE a program that prompts for and inputs a temperature in degrees Kelvin, then idiotproofs, then calculates the associated temperature in degrees Celsius, then outputs the temperature in degrees Celsius
Solution
// C++ code conversion kelvin and celsius
#include <iostream>
 #include <iomanip>
 #include <fstream>
 #include <vector>
 #include <stdlib.h>   
 #include <math.h>
using namespace std;
 int main()
 {
 double temperature_kelvin;
 
 while(true)
 {
 // getting user input
 cout << \"Enter temperature in kelvin: \";
 cin >> temperature_kelvin;
// idiot proof
 if (cin.fail())
 {
 cout << \"Invaid Input\" << endl;
 cin.clear();
 cin.ignore(100, \'\ \');
 }
else if(temperature_kelvin < 0)
 cout << \"Temperature should be non-negative\ \";
else
 break;
 }
 // conversion
 double celsius = temperature_kelvin - 273.15;
cout << \"\ Temperature: \" << celsius << \" degree celsius\ \";
return 0;
 }
/*
 output:
Enter temperature in kelvin: abs
 Invaid Input
 Enter temperature in kelvin: 100
Temperature: -173.15 degree celsius
 */

