Question: In C++ Write a program that will prompt the user for three numbers and displays them in ascending order. Use the IF/ELSEIF/ELSE construct. You may
In C++
Write a program that will prompt the user for three numbers and displays them in ascending order. Use the IF/ELSEIF/ELSE construct. You may also use nested IF statements if you'd like.
- First, the program will prompt the user for each of the three numbers.
- Next find the smallest value of the three.
- Then decide which of the other two is the largest value.
- Then determine middle value.
- Then have the program display the three numbers in ascending order.
Be sure to do the following:
- Determine what the input will be, it's data type, and assign a variable for each value.
- Determine what the output will be. Do you need new variables for the output or can you use the input again? There is no right or wrong answer here. Its also possible you may have to develop your algorithms before you can decide whether you will use new variables for your output or just use the input variables. You can always change your mind if you find you need to.
- Do you need any formulas?
- Create an initial algorithm of the basic steps.
- Develop the refined algorithm from the initial algorithm.
Be sure to include with your program as documentation:
- The Program Prologue
- The Input data
- The Output data
- Any Formulas you may have.
- The Initial Algorithm
- The Refined Algorithm
- The code to pause your output screen.
NOTE 2:
- DO NOT use the "return 0" code, end, break, or exit to force an exit from within your IF/ELSE structure.
- Let the program progress to the end of the main function.
- The end of the main function is the only place that the return 0 should be placed.
- A switch statement is the only place that the break command should be placed.
- Declare all variables within the data declaration section.
- DO NOT get input on the same line as a variable declaration.
- DO NOT place an equation for computation on the same line as declaring a variable.
- DO NOT use arrays or any other advanced topics that haven't been covered yet.
NOTE 2: 1. Declare all variables within the data declaration section of each class and method. (-5) 2 Do not get input on the same line as a variable declaration. (-5) 3. Do not place an equation for computation on the same line as declaring a variable. (-5)
Test your program with the following sets of data:
- First number: 3 Second number: 2 Third number: 1
- First number: 3 Second number: 1 Third number: 2
- First number: 1 Second number: 2 Third number: 3
- First number: 1 Second number: 3 Third number: 2
- First number: 2 Second number: 1 Third number: 3
- First number: 2 Second number: 3 Third number: 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
