Write a function or script to convert units of energy from o
Write a function or script to convert units of energy from one to another the possible units are: J, kcal, cal, BTU, and kwh.
conversion factors are:
1 BTU=1055 J
1 BTU = 252.164 cal
1kcal = 1000cal
1kW=1000J/s
1 h = 3600s
Solution
converter(h, kcal, BTU, kw) //Theis is the function for converting given enrgy units
{
float joule, btuCalorie, joulePerSecond, calorie;
int second;
Joule= 1055*BTU; // From BYU to Joule
printf(\"%f BTU contains %f joule\", BTU, joule);
btuCalorie= 252.164*BTU; //From BTU to Calorie
printf(\"%f BTU contains %f calorie\", BTU, btuCalorie);
calorie= 1000*kcal; //from Kilocalorie to calorie
printf(\"%f kcal contains %f calorie\", kcal, calorie);
joulePerSecond= 1000*kw; //from Kilowatt to joule per second
printf(\"%f kw contains %f joulePerSecond J/s\", kw, joulePerSecond);
second= 3600*h; //From hours to seconds
printf(\"%d h contains %d seconds\", h, seconds);
return(jule, btuCalorie, joulePerSecond, calorie, second);
}
