COSC 1337 – Programming Fundamentals II
Program 4 Hint
You can use a standard sequential search to search the array for the package weight -- you only need a very minor modification.
The standard sequential search stops when an exact match for the search item is found in the array. A standard search will not work for this problem since all possible weights (1 - 50) are not stored in the array. For example, a 6 pound package would not have a matching weight -- the shipping charge would be the same as for a 7 pound package.
The required modification is simple. You need a search that stops when the package weight is less than or equal to the weight in the array.
© Austin Community College 2016. The content on this page is licensed under a
Creative Commons Attribution 4.0 International License.
Last updated: January 12, 2013