Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this program, you will add two user entered heights in feet'inches format ( eg: 5 ' 1 0 ' ' ) and print the

In this program, you will add two user entered heights in feet'inches" format (eg: 5'10'') and print the sum of the two heights in the feet'inches" format as well as in centimeters.
Write your C++ program called Lab3C.cpp that does the following:
Prompt for and read in first height using printf and scanf appropriately. Use integer variables to store feet and inches for the first height (feet 1 and inches 1).You need to use the correct format specifier in scanf to scan the two values.
Prompt for and read in second height using printf and scanf appropriately. Use integer variables to store feet and inches for the second height (feet2 and inches2).
Compute the sum of the two user entered heights.
For calculating sum in feet'inches" format, add two feet and two inches of the two heights in two integer variables (totalFeet and totalinches).
Also, compute the carryover after you sum the inches of the two heights because 1 foot =12 inches. For example, if user enters 5'8'' and 5'7'' for first and second heights respectively, then the sum should be 11'3'' instead of 10'15''.
Sample Output:
$ ./a.out
Enter first height (format: 5'10"): 5'9"
Enter second height (format: 5'10"): 4'8"
Sum of two heights =10'5"(317.50 centimeters)
$ ./a.out
Enter first height (format: 5'10"): 5'4"
Enter second height (format: 5'10"): 5'3"
Sum of two heights =10'7"(322.58 centimeters)
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions

Question

please dont use chat gpt 2 2 4 . .

Answered: 1 week ago