Code:
// Name: John King
// Date: Monday February 15 at 8:oo AM
// Desc: The purpose of this project is to modularize our Project One. Also to add
// conversions in for Kelvi and inches.
#include <stdio.h>
//Prototypes
void getInput(int* pFahrenheit, int* pFeet, int* pPounds);
int calc(int fahrenheit, int feet, int pounds, float *celsius, float *kelvin, float
*meters, float *inches, float *kilograms);
float calcTemp(int fahrenheit, float *celsius, float *kelvin);
float calcDistance(int feet, float *meters, float *inches);
float calcWeight(int pounds, float *kilograms);
void display (int fahrenheit, float celsius, float kelvin, int feet, float
meters, float inches, int pounds, float kilograms);
//calls all the other functions
int main(void)
{
int fahrenheit, feet, pounds;
float *celsius, *kelvin, *meters, *inches, *kilograms;
getInput(&fahrenheit, &feet, £s);
calc(fahrenheit, feet, pounds, *celsius, *kelvin, *meters, *inches, *kilograms);
display(fahrenheit, *celsius, *kelvin, feet, *meters, *inches, pounds, *kilograms);
return 0;
}
void getInput(int* pFahrenheit, int* pFeet, int* pPounds)
{
printf("\nName: John King");
printf("\nPlease enter an integer value for Fahrenheit:");
scanf("%d", pFahrenheit);
printf("\nPlease enter an integer value for Feet:");
scanf("%d", pFeet);
printf("\nPlease enter an integer value for Pounds:");
scanf("%d", pPounds);
}
int calc(int fahrenheit, int feet, int pounds, float *celsius, float*kelvin, float
*meters, float *inches, float *kilograms)
{
calcTemp(fahrenheit, *celsius, *kelvin );
calcDistance(feet, *meters, *inches);
calcWeight(pounds, *kilograms);
}
float calcTemp(int fahrenheit, float *celsius, float *kelvin)
{
*celsius = (fahrenheit - 32) / 1.8;
*kelvin = *celsius + 273.15;
}
float calcDistance(int feet, float *meters, float *inches)
{
*meters = feet / 3.2808399;
*inches= feet * 12;
}
float calcWeight(int pounds, float *kilograms)
{
*kilograms = pounds / 2.20462262;
}
void display(int fahrenheit, float celsius, float kelvin, int feet, float meters, float
inches, int pounds, float kilograms)
{
printf("\n%20s%20s%20s%20s%20s%20s", "Original", "Value", "Converted To",
"Value", "Converted To", "Value");
printf("\n%20s%20s%20s%20s%20s%20s", "--------", "-----", "------------", "-----",
"------------", "-----");
printf("\n%20s%20d%20s%20.3d%20s%20.3d", "Fahrenheit", fahrenheit, "Celsius", celsius,
"Kelvin", kelvin);
printf("\n%20s%20d%20s%20.3d%20s%20.3d", "Feet", feet printf("\n%20s%20d%20s%20.3d", "Pounds", pounds, "Kilograms", kilograms);
printf("\n\n");
}