Edhesive Computer Science 2.3 Help!

The language used is Python and the question asks - Write a program that inputs the length of two pieces of fabric in feet and inches (as whole numbers) and prints the total.
Enter the Feet for the first piece of fabric: 3
Enter the Inches for the first piece of fabric: 11
Enter the Feet for the second piece of fabric: 2
Enter the Inches for the second piece of fabric: 5
It displays:
Feet: 6 Inches: 4

So far I have this:
x=float(input("Enter the Feet for the first piece of fabric:"))
y=float (input("Enter the Inches for the first piece of fabric:"))
j=float (input("Enter the Feet for the second piece of fabric:"))
k=float (input("Enter the Inches for the second piece of fabric:"))
print ("Total: "+str((x+j%(k+y))
And it just ain't working
Can someone help?

You are viewing a single comment. View All
heyitsmarcus (288)

Hey @linda231,

I can see why you were originally getting an error. The amount of beginning parenthesis you have in the final `print` line of your code doesn't match the amount of ending parenthesis. You needed two more at the end for the code to compile.

However

Your logic for the program is incorrect. I'm laying this out in a format that should be easier to understand. I would personally change `x,y,j,k` to variables that make more sense to what they are such as `feet1`, `inches1`, `feet2`, `inches2`. And that is what I did in my example for easier understanding.

``````import math
feet1=float(input("Enter the Feet for the first piece of fabric: "))
inches1=float(input("Enter the Inches for the first piece of fabric: "))
feet2=float(input("Enter the Feet for the second piece of fabric: "))
inches2=float(input("Enter the Inches for the second piece of fabric: "))
#Get the initial total amount of feet
initialFeet = feet1 + feet2
#Get the initial total amount of inches
initialInches = inches1 + inches2
#Get the remaining inches which is a modulus of 12 (12 inches in 1 foot)
remainingInches = initialInches % 12
#This total has to be divided by 12 and then have a floor done on it which will remove any decimal values
#The total feet will be the initial feet (feet1 and feet2) plus the additional calculated feet

print ("Total: Feet: " + str(totalFeet) + " Inches: " + str(remainingInches))``````

And here is a copy of the program above: https://repl.it/@heyitsmarcus/Feet-and-Inches