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 Kelvin and inches.
#include <stdio.h>
//Prototypes
void getInput(int* pFahrenheit, int* pFeet, int* pPounds);
int calc(int* pCelsius, int* pKelvin, int* pMeters, int* pInches, int* pKilograms);
float calcTemp(int fahrenheit, int* pCelsius, int* pKelvin);
float calcDistance(int feet, int* pMeters, int* pInches);
float calcWeight(int pounds);
void display (int fahrenheit, int celsius, int kelvin, int feet, int
meters, int inches, int pounds, int kilograms);
//calls all the other functions
int main(void)
{
int fahrenheit, feet, pounds;
int celsius, kelvin, meters, inches, kilograms;
getInput(&fahrenheit, &feet, £s);
calc(&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\n");
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* pCelcius, int* pKelvin, int* pMeters, int* pInches, int* pKilograms)
{
int fahrenheit, feet, pounds;
int celsius, kelvin, meters, inches, kilograms;
calcTemp(fahrenheit, &celsius, &kelvin );
calcDistance(feet, &meters, &inches);
calcWeight(pounds);
}
float calcTemp(int fahrenheit, int* pCelsius, int* pKelvin)
{
*pCelsius = (fahrenheit - 32) / 1.8;
*pKelvin = *pCelsius + 273.15;
return *pCelsius, *pKelvin;
}
float calcDistance(int feet, int* pMeters, int* pInches)
{
*pMeters = feet / 3.2808399;
*pInches= feet * 12;
return *pMeters, *pInches ;
}
float calcWeight(int pounds)
{
int* pKilograms;
*pKilograms = pounds / 2.20462262;
return *pKilograms ;
}
void display(int fahrenheit, int celsius, int kelvin, int feet, int meters, int
inches, int pounds, int kilograms)
{
printf("\n%15s%15s%15s%15s%15s%15s", "Original", "Value", "Converted To",
"Value", "Converted To", "Value");
printf("\n%15s%15s%15s%15s%15s%15s", "--------", "-----", "------------", "-----",
"------------", "-----");
printf("\n%15s%15d%15s%15.3d%15s%15.3d", "Fahrenheit", fahrenheit, "Celsius", celsius,
"Kelvin", kelvin);
printf("\n%15s%15d%15s%15.3d%15s%15.3d", "Feet", feet, "Meters", meters, "Inches",
inches);
printf("\n%15s%15d%15s%15.3d", "Pounds", pounds, "Kilograms", kilograms);
printf("\n\n");
}