Computer Programming I
Lab Project #7 - Sorting
THE PROBLEM: Design and write a program in C++ that
will read in up to 10 numbers, store them in an array, then sort them. Your program will check each number as it
is entered. If the number is in the
range 1..100, it is a legal value and will be placed in the array. If the number entered is 0, the program will
stop taking input, and then will sort the numbers and print them out. If the value entered is any other value (not
in range 0..100) the program will print out an error message and force the user
to enter the value again. Bad values
will not be placed into the array and will not be sorted.
Your program
will also halt entry if more than 10 numbers are entered.
Example:
Enter
numbers:
4
2
6
9
1
0
Entry
complete.
Sorted
values:
1
2
4
6
9
THE DESIGN: Recall the steps in problem-solving, go through each one in this project. Your top-down design, written on a computer, should be written at the top of your program as comments. The design must be complete, with each step of the algorithm matching the actions of your program. Your design will be compared to your program.
IMPLEMENTATION: In your program you must write several
functions. You should not use the bubble
sort algorithm, use one of the other sorts discussed in class.
WHAT TO HAND IN: You must hand in your design as
comments at the top of your program and as comments for each function, your
program and your sample test runs on paper.