SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,julia Lobur
Chapter:
Functions For All Subtasks
Exercise:
Programming Projects
Question:12 | ISBN:9780321531346 | Edition: 7

Question

(You need to do Programming Projects 8 and 11 before doing this programming project.) Write a program that combines the functions of Programming Projects 8 and 11. The program asks the user if he or she wants to convert lengths or weights. If the user chooses lengths, then the program asks the user if he or she wants to convert from feet and inches to meters and centimeters or from meters and centimeters to feet and inches. If the user chooses weights, a similar question about pounds, ounces, kilograms, and grams is asked. The program then performs the desired conversion. Have the user respond by typing the integer 1 for one type of conversion and 2 for the other. The program reads the user’s answer and then executes an if-else statement. Each branch of the if-else statement will be a function call. The two functions called in the if-else statement will have function definitions that are very similar to the programs for Programming Projects 8 and 11. Thus, these functions will be fairly complicated function definitions that call other functions in their function bodies; however, they will be very easy to write by adapting the programs
you wrote for Programming Projects 8 and 11. Notice that your program
will have if-else statements embedded inside of if-else statements, but
only in an indirect way. The outer if-else statement will include two
function calls as its two branches. These two function calls will each in
turn include an if-else statement, but you need not think about that.
They are just function calls and the details are in a black box that you cre-
ate when you define these functions. If you try to create a four-way
branch, you are probably on the wrong track. You should only need to
think about two-way branches (even though the entire program does ulti-
mately branch into four cases). Include a loop that lets the user repeat this
computation for new input values until the user says he or she wants to
end the program.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Sorry the answer is not available at the moment…

If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.

Spread the 'tradition of sharing'.