Question: (15 points) Write a program that converts kilograms to pounds, and vice versa. Your program should ask the user to input one of the following:

(15 points) Write a program that converts kilograms to pounds, and vice versa. Your program should ask the user to input one of the following:

a number followed by k

a number followed by l

The k and l represent kilograms and pounds, respectively. Your program reads the number in one unit, converts it to the other unit, and outputs the result.

Note that the conversion equations are:

kg = 0.4535970244 lb

lb = 2.2046 kg

For the conversion rates, you must use named constants.

Running sessions of your program should look like the following:

Enter a weight (e.g., 73k, 160l) => -34k

Invalid weight... The weight should be zero or positive

Enter a weight (e.g., 73k, 160l) => 34g

Invalid unit... The unit should be either k or l

Enter a weight (e.g., 73k, 160l) => 43k

43kg is 94.7978 lb

(15 points) Write a C++ program that asks a user for an integer, reads it, and outputs one of the following:

foo: if the integer is a multiple of 3

bar: if the integer is a multiple of 5

foobar: if the integer is a multiple of 3 and 5

Otherwise, the program outputs the input integer itself. You are not allowed to use in your program the number 15 or any expression that evaluates to 15 (e.g., 3 * 5, or num1 * num2 where num1 and num2 contain 3 and 5, etc).

Running sessions of your program should look like the following:

Enter an integer => 33

Enter an integer => 55

Enter an integer => 75

Enter an integer => 76

Please write the code in C++ form.

Thank you

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!