Lab 9: Arrays This lab accompanies Chapter 8 of Starting Out with Programming Logic & Design . Name: ___________________________ Lab 9.1 Arrays and Pseudocode Critical Review An array allows you to store a group of items of the same data type together in memory. A variable stores just a single value, and oftentimes can be cumbersome to work with when your program has similar values. Values stored in an array are called elements. Each element has a subscript that makes it unique. An array is defined as follows: Declare Integer numbers[10] Integer defines the type of numbers that can be stored, numbers is the name of the array, and [10] is how many numbers can be stored. In most languages, the first element is assigned the subscript of 0, so the above array actually runs from 0 to 9. Constant variables can also be used to declare the size of an array. Constant Integer SIZE = 5 Declare Integer numbers[SIZE] = 847, 1238, 48, 123, 840 Elements in the array 847 1238 48 123 840 0 1 2 3 4 Subscript or Index starting a 0 Loops are generally used to step through an array. This can be done using any type of loop and for any process such as filling, calculating, searching, sorting, or outputting elements of the array. This lab examines the various ways of working with arrays by writing pseudocode. Read the following programming problem prior to completing the lab. The American Red Cross wants you to write a program that will calculate the average pints of blood donated during a blood drive. The program should take in the number of pints donated during the drive, based on a seven hour drive period. The average pints donated during that period should be calculated and displayed. Additionally, the highest and the lowest number of pints donated should be determined and displayed. Write a loop around the program to run multiple times. Step 1: Declare the following variables: An array named pints of the data type Real of size 7 A variable named totalPints of the data type Real A variable named averagePints of the data type Real initialized to 0 A variable named highPints of the data type Real initialized to 0 A variable named lowPints of the data type Real initialized to 0 Module main() //Declare local variables Declare String again = no ____________________________________ ____________________________________ ____________________________________ ____________________________________ ____________________________________ While again == no //module calls below Display Do you want to run again: yes or no Input again End While End Module Step 2: Write a module call to a module named getPints that passes the pints array. Additionally, write a module header named getPints that accepts the pints array. (Reference: Passing an Array as an Argument to a Function, page 295). //Module call Call ________________(______________) //Module header Module ___________(Real ______________[ ]) Step 3: Write a for loop that runs 7 times using the counter variable. Inside the for loop, allow the user to enter values into the array. (Reference: Using a Loop to Step Through an Array, page 273). Declare Integer counter = 0 For __________________ = 0 to _______________ Display Enter pints collected: Input ___________[_________] End For Step 4: Write a function call to a module named getTotal that passes the pints array and the totalPints variable. Additionally, write a function header named getTotal that accepts the pints array and the totalPints variable. //Function call totalPints = ______________(______________, ___________) //Function header Function _________(Real ______________[ ], Real __________) Step 5: Write a for loop that runs 7 times using the counter variable. Inside the for loop, total up the values of the array and store in the variable totalPints . Also, return the correct variable from the function. (Reference: Totaling the Values in an Array, page 289). Declare Integer counter = 0 Set totalPints = 0 For __________________ = 0 to _…
Looking for a solution written from scratch with No plagiarism and No AI?
WHY CHOOSE US?
We deliver quality original papers |
Our experts write quality original papers using academic databases.We dont use AI in our work. We refund your money if AI is detected |
Free revisions |
We offer our clients multiple free revisions just to ensure you get what you want. |
Discounted prices |
All our prices are discounted which makes it affordable to you. Use code FIRST15 to get your discount |
100% originality |
We deliver papers that are written from scratch to deliver 100% originality. Our papers are free from plagiarism and NO similarity.We have ZERO TOLERANCE TO USE OF AI |
On-time delivery |
We will deliver your paper on time even on short notice or short deadline, overnight essay or even an urgent essay |