problem with structure, and parameter passing.
My teacher marked off for the structure matching specs and correct parameter passing
COP 2220Project 250 pointsDue electronically Friday, 2-17, at 8:00 a.m. Preliminary structure and IPO chart due Monday, February 6NOTE: From now on, the first output of all programs you write should be your name.Modify your program from Project 1 into a modularly designed program. Inaddition to the previously specified calculations, the program should alsocalculate the Kelvin temperature from the Fahrenheit (or more easily, the Celsius) and the feet to inches. Use a six-column report as shown in the example output.Display floating point values in the report using 3 places of precision. Kelvin should be double but inches should be int. Create the report with decimal places aligned correctly with the implied decimal of the integers. The resulting program *must* match the structure chart listed below.
Code:
.
main
|
-----------------------------------
| | |
getInput calc display
|
--------------------
| | |
calcTemp calcDistance calcWeight
and calcWeight *must* match the following prototype exactly. double calcWeight(int pounds);These requirements are worth significant points.This program is somewhat overmodularized but is an exercise in the different ways to pass data throughout functions in a program.
Code:
#include <stdio.h>
void getInput (int* pFahr, int* pFeet, int* pLbs);
void calcTDW (int fahr, int feet, int lbs);
void calcTemp (int fahr, double* pCels, double* pKelvin);
void calcDistance (int feet, double* pMeters, int* pInches);
double calcWeight (int lbs);
void display (int fahr, double cels, double kelvin, int feet, double
meters, int inches, int lbs, double kilos);
int main (void)
{
printf("Name: Bryan Benson");
printf("\n\n");
int fahr, feet, lbs, inches;
double cels, meters, kilos;
double kelvin;
getInput (&fahr, &feet, &lbs);
calcTDW (fahr, feet, lbs);
calcTemp (fahr, &cels, &kelvin);
calcDistance (feet, &meters, &inches);
kilos = calcWeight (lbs);
display (fahr, cels, kelvin, feet, meters, inches, lbs, kilos);
return 0;
}
void getInput (int* pFahr, int* pFeet, int* pLbs)
{
printf ("Enter an integer value for Fahrenheit : ");
scanf ("%d", pFahr);
printf ("\nEnter an integer value for Feet : ");
scanf ("%d", pFeet);
printf ("\nEnter an integer value for Pounds : ");
scanf ("%d", pLbs);
printf ("\n\n");
}
void calcTDW (int fahr, int feet, int lbs)
{
void calcTemp (int fahr, double* pCels, double* pKelvin);
void calcDistance (int feet, double* pMeters, int* pInches);
double calcWeight (int lbs);
}
void calcTemp (int fahr, double* pCels, double* pKelvin)
{
*pCels = 5.0 * (fahr - 32) / 9.0;
*pKelvin = *pCels + 273;
}
void calcDistance (int feet, double* pMeters, int* pInches)
{
*pMeters = 0.3048 * feet;
*pInches = 12 * feet;
}
double calcWeight (int lbs)
{
double kilos;
kilos = lbs / 2.204;
return kilos;
}
void display (int fahr, double cels, double kelvin, int feet, double
meters, int inches, int lbs, double kilos)
{
printf ("\n Original Value Converted to Value ");
printf ("Converted to Value ");
printf ("\n -------- ----- ------------ ----- ");
printf ("------------ ----- ");
printf ("\nFahrenheit");
printf ("%12d", fahr);
printf (" Celsius");
printf ("%11.3f", cels);
printf (" Kelvin");
printf ("%14.3f", kelvin);
printf ("\n Feet");
printf ("%12d", feet);
printf (" Meters");
printf ("%11.3f", meters);
printf (" Inches");
printf ("%10d", inches);
printf ("\n Pounds");
printf ("%12d", lbs);
printf (" Kilograms");
printf ("%11.3f", kilos);
printf ("\n\n");
}