Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have to develop a C++ Program that converts units of measure, with the below requirements. I can only use loops and functions. My issue

I have to develop a C++ Program that converts units of measure, with the below requirements. I can only use loops and functions. My issue is I know what the end result is supposed to be and the equations for it, but I don't know how to start it and how to put it all together.

Program Requirements: 1. The program should provide an initial description. 2. The user should be prompted to enter the dimension (length, mass, or time). 3. The user should be given a choice of initial units and final units for each dimension as follows: ? Length: m, ft, cm or in ? Mass: kg, g or slug ? Time: h, min or s Note that the initial unit cannot be the same as the final unit, but there are still many possible conversions. For example, with length there are 12 possible conversions

m to ft ft to m cm to m in to ft
m to in ft to cm cm to in in to cm
m to cm ft to in cm to ft in to m

Similarly, there are multiple conversion possibilities for mass and time.

4. The units should be read as strings and any combination of uppercase and lowercase letters can be used. The user should be able to use the full unit name (plural or singular) or the symbol (for example, meters, meter or m). Use a function to convert the input unit to all lowercase letters. Only the unit symbol should be used in the table. 6. The table should include a heading with the dimension name and the units. The number of digits displayed must match the users specifications. The table should be right justified and all decimal points should be aligned. See the sample table on the previous page. 7. The program should calculate the number of lines in the table based on the user inputs specifying starting value, ending value and increment. The number of lines in the table must be at least 3, but not more than 25. If the ending value is not a multiple of the increment, the table should end with the last possible value before the ending value specified. For example, if the user specifies the following value: Starting value: 10 Ending value: 100 Increment: 20 The program should determine that 5 lines are needed and that the last value in the table should be 90 (not 110). 8. Use loops allow the user to correct any bad inputs (and provide a suitable error message). Bad inputs should include: ? Choice of dimension (length, mass or time) ? Choice of units (with correct spelling) for each dimension ? Starting and ending unit cannot be the same ? Number of digits > 0 ? Starting value, increment and ending value must all be positive. ? Number of lines in the table must be from 3 to 25. If this condition fails, the user should re-enter the starting value, increment and ending value. 9. Efficiency: The program must be efficient or else it could become exceeding long and significant grade penalties will apply. For example, a poorly written program might repeat the code for generating a table dozens of times for the many possible conversions. An efficient program would only have one set of instructions to generate a table and the table would use the assigned values for dimension, units, digits, starting value, etc.

10. Give the user the option of re-running the program (use a do while loop). 11. The program should use at least 3 functions, including: a. Function to convert a string to all lower case. b. Function that returns the appropriate conversion factor based on the starting unit and ending unit. c. Function of your choice (it must be useful and well-designed).

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

Students also viewed these Databases questions

Question

explain what is meant by the terms unitarism and pluralism

Answered: 1 week ago