Click here to Skip to main content
15,912,977 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
PLEASE HELP, ITS A PART OF MY GRADE, I'VE TRIED SO MANY TIMES, BUT WHEN I TURN IT IN ITS ALWAYS WRONG. THIS IS MY LAST CHANCE.




1. The user will enter two whole numbers for the meters and centimeters.

2. The program will then output the equivalent number of feet and inches.

3. Use these conversion factors:

. one meter equals 100 centimeters,
. one centimeter equals 0.393700787 inches and
. there are 12 inches in a foot.


Sample run:

Enter the number of meters: 342
Enter the number of centimeters: 45
That's equivalent to 1123 feet and 6.28 inches.


1. First, determine the total number of centimeters.
2. Then convert that to total inches.
3. Divide (integer division) total inches by 12 to determine the total number of feet.
4. Use modulus on total inches (get remainder) by 12 to determine the remaining number of inches. Feet will be an integer.
5. To display inches, round it to two decimal places.

What I have tried:

Python
meter = int(input("Type meters: "))
centimeter = int(input("Type centimeter value: "))

meter2centimeter = 100
centimeter2inches = 0.393700787
foot2inches = 12

feet = meter * centimeter2inches * meter2centimeter/foot2inches
inches = centimeter * centimeter2inches

print(feet)
print(inches)
Posted
Updated 16-Feb-18 14:50pm
v3

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!

I'll give you a little help, but no code - this is your homework, not mine!

Start by reading the question.
From that, you have to read two values from the user, and convert them to imperial measurements.
So the first thing you need to do with the two numbers is convert them to a "common" measure: convert the meters to centimeters (you have that conversion factor) and add it to the centimeters to get a total in centimeters.
Then convert the centimeters into inches (you have that factor as well).
Then find out how many whole feet there are in the number of inches (hint: integer division will get rid of fractional parts) and store that. Either using the feet count or the '%' (modulus) operator find out the remaining number of inches.
Print them.

This is not difficult - just stop SHOUTING, stop panicking, and sit down and think.
 
Share this answer
 
In your code, you missed:
Quote:
1. First, determine the total number of centimeters.

And this matters because meters and centimeters and not exact multiples of inches and foot.

Advice: Take a sheet of paper and a pencil, practice the conversion with examples until you master the algorithm. Read carefully the requirement, the 5 steps is your algorithm.
Once you master the details, write your code.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900