I need help with this assignment for my computer programming class.....

I honestly have no idea what Im doing!!!!

Convert a person's height from meters into feet and inches (rounded to the nearest whole numbers) and display the result on the screen. The height must be entered by the user in metric units and may contain decimal portions.

SOFT COPY

Height Converting Program
Designed by Randolph Gibson - 15 January 2001
Coded by Joe Student - 16 January 2001

This program will convert a person's height from meters
into feet and inches (rounded to the nearest inch) and
display the result on the screen. The height must be
entered in metric units and may contain decimal portions.
The answer will be displayed in whole feet and inches.

Enter the person's height in meters: 1. 8

That height is equivalent to 5 feet and 11 inch(es).

does anyone know how to code it?

2
Contributors
9
Replies
10
Views
9 Years
Discussion Span
Last Post by Salem

Can you convert metres into centimetres?
Can you convert centimetres to inches?
Can you see where this is going?

I can do the math lol.

its the coding i need help with.

So it's just printf() and scanf()

I started like this...

* Program: Height Converting Program *
* Designed by: Randolph U. Gibson - January 1, 2004 *
* Coded by: Stephanie September 5, 2009 *
****************************************************/

#include <stdio.h>

int main (void)

{

printf ("Height Converting Program\n");
printf ("Designed by Randolph U. Gibson - 1 January 2004\n");
printf ("Coded by Stephanie September 5, 2009\n\n");

printf ("This program will convert a person's height from meters\n");
printf ("into feet and inches (rounded to the nearest inch) and\n");
printf ("display the result on the screen. The height must be\n");
printf ("entered in metric units and may contain decimal portions.\n");
printf ("The answer will be displayed in whole feet and inches.\n\n");

}

and in the end Im supposed to convert meters to feet and inches but im not really clear on how to code that...

the statement in the output will read:

Enter the person's height in meters: 1.8

That height is equivalent to 5 feet and 11 inch(es).

okay i got the program to convert meters into feet...

how do I get it to produce meters into feet and inches at the same time
?

like 3 meters is

___ feet and _____ inches.

feet = x / 12
inch = x % 12

for some reason when i enter the meters into the program the ending result doesnt give the calculated numbers it just shows FEET feet and INCHES inch(es).

``````/**************************************************
*Program: hconvert.c                              *
*Designed by: Randolph Gibson - 15 January 2001   *
*Coded by: stephanie - 02 September 2009          *
**************************************************/
#include <stdio.h>
#define FACTOR 2.54
double METERS;
int INCHES;
double FEET;

int main (void)
{

printf ("Height Converting Program\n");

printf ("Designed by Randolph Gibson - 15 January 2001\n");
printf ("Coded by John Nick - 02 September 2009\n\n");
printf ("This program will convert a person's height from meters \n");
printf ("into feet and inches (rounded to the nearest inch) and \n");
printf ("display the result on the screen. The height must be \n");
printf ("entered in metric units and may contain decimal portions. \n");
printf ("The answer will be displayed in whole feet and inches.\n\n");
/* Data Input Section */
printf ("Enter the person's height in meters:");
scanf ("%f", METERS);
/* Caluclation Section */
INCHES = METERS * 100 / FACTOR;
FEET = INCHES / 12;
INCHES = INCHES % 12;
/*Output Section */
printf ("That height is equivalent to " "FEET" " feet and " "INCHES" " inch(es).");
return (0);
}``````

Edited by azn_sweet: n/a

Well you need to read how printf() and scanf() work. `scanf ("%f", METERS);` should be `scanf ("%f", [B]&[/B]METERS);` Now go find out how to print parameters using printf as well (%d and all that jazz)