Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program that adds two weights. Both weights are expressed in pounds and ounces and the resulting sum should also be expressed in pounds
Write a program that adds two weights. Both weights are expressed in pounds and ounces and the resulting sum should also be expressed in pounds and ounces. Note that there are 16 ounces in a pound.
Given the following initial values:
pounds1 = 7 ounces1 = 8 pounds2 = 9 ounces2 = 11
the program should produce the following output:
7 pounds and 8 ounces added to 9 pounds and 11 ounces is equal to 17 pounds and 3 ounces
Please note the following:
- Do not include the above variable initialization statements in your code. They will be provided for you with each CodeRunner test case.
- You can assume all 4 variables will always be assigned integer values.
- You need to use the modulus (%) and floor division (//) operators in your calculations.
For example:
Test | Result |
---|---|
pounds1 = 7 ounces1 = 8 pounds2 = 9 ounces2 = 11 | 7 pounds and 8 ounces added to 9 pounds and 11 ounces is equal to 17 pounds and 3 ounces |
pounds1 = 3 ounces1 = 4 pounds2 = 5 ounces2 = 6 | 3 pounds and 4 ounces added to 5 pounds and 6 ounces is equal to 8 pounds and 10 ounces |
python please faster
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started