Start Raptor and save your document as hw_w13. The .rap file extension will be added automatically. Start by adding a Comment box that declares your variables. Add your loop to run multiple times and your module calls in the main module.
DentalProStart Raptor and save your document as hw_w13. The .rap file extension will be added automatically. Start by adding a Comment box that declares your variables. Add your loop to run multiple times and your module calls in the main module.
Add the getPints( ) module in main. Go to the getPints() module and add the following inside the module:
- Add an assignment statement that sets counter to 1. Remember, counter has to be set to one because Raptor arrays must start at 1, not 0.
- Add a loop that runs as long as counter is less than 7. Remember, this should be written as counter > 7 because if yes, then the loop ends.
- Add an input statement that asks the user to enter number of pints, storing the answer in the array. The input should be entered as below.
- Add an assignment statement that will increment counter by 1.
Add the getTotal( ) module in main. Go to the getTotal() module and add the following inside the module:
- Add an assignment statement that sets counter back to 1.
- Add an assignment statement that sets totalPints to 0.
- Add a loop that runs 7 times.
- Add an assignment statement that accumulates the value of the array. The input should be as below:
- Add an assignment statement that will increment counter by 1.
Add the getAverage( ) module in main. Go to the getAverage() module and add the following inside the module:
- Add an assignment statement that sets counter back to 1.
- Add an assignment statement that sets averagePints to totalPints divided by 7
Add the getHigh( ) module in main. Go to the getHigh() module and add the following inside the module:
- Add an assignment statement that sets counter to 2. This refers to the second location in the array.
- Add an assignment statement that sets highPints to the 1 index of the pints array.
- Add a loop that iterates 7 times.
- Inside the loop, add a selection statement that determines if pints in the counter location is greater than highPints.
- If that is true, then set highPints to pints in the counter location.
- Increment counter by 1.
Add the getLow( ) module in main. Go to the getLow() module and add the following inside the module:
- Add an assignment statement that sets counter to 2. This refers to the second location in the array.
- Add an assignment statement that sets lowPints to the 1 index of the pints array.
- Add a loop that iterates 7 times.
- Inside the loop, add a selection statement that determines if pints in the counter location is less than lowPints.
- If that is true, then set lowPints to pints in the counter location.
- Increment counter by 1.
Add the displayInfo( ) module in main. Go to the display() module and add the following inside the module:
- Display the averagePints variable
- Display the highPints variable
- Display the lowPints variable
Using the following input values, check your results. If there are errors, verify steps 1 through 10.
Element | 34 | 39 | 25 | 18 | 43 | 31 | 12 |
Output should be as follows:
The average pints collected: 28.8571
The highest amount was: 43
The lowest amount was: 12
- 9 years ago
Purchase the answer to view it
- hw_w13.zip