Can you guys help me to resolve this lab asap ?

profilebtech14
nillaboratory4_1.docx

LABORATORY #4

4

Laboratory # 4: Arrays

Laboratory #4 we are learning how use array to solve problem within RAPTOR. Arrays allow us to store a group of items of the same data type together in memory. The elements stored in the array are called elements; each element has a unique subscript.

Name: ___________________________

Lab 4.1 – Arrays and Pseudocode (10 pnts)

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, the program should stop when the user press the y key.

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 for loop that runs 7 times using the counter variable. Inside the for loop, allow the user to enter values into the array named pints

Declare Integer counter = 0

For __________________ = 0 to _______________

Display “Enter pints collected:”

Input ___________[_________]

End For

Step 3: 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.

Declare Integer counter = 0

Set totalPints = 0

For __________________ = 0 to _______________

Set _________ = ________ + ______________[________]

End For

Return _________________

Step 4: Write a statement that will calculate the average pints donated over the drive period. Also, return the correct variable from the function.

averagePints = ________________ / _________________

Return ______________________

Step 5: Write the code that will determine the highest value in an array. Also, return the correct variable from the function

Set highPints = pints[________]

Set index = 1

For index = 1 to 6

If _______________[_______] > highPints Then

Set ____________ = __________[_______]

End If

End For

Return ______________________

Step 6: Write the code that will determine the lowest value in an array. Also, return the correct variable from the function.

Set lowPints = pints[________]

Set index = 1

For index = 1 to 6

If _______________[_______] < lowPints Then

Set ____________ = __________[_______]

End If

End For

Return ______________________

Lab 4.2 – Checking the Work (10 pnts)

Using the program from Lab 6, complete the following checks for a better understanding of your work.

Step 1: Imagine the following number of pints were entered into the array.

Element

34

39

25

18

43

31

12

Index

0

1

2

3

4

5

6

Step 2: Complete the following chart by writing what the counter and the totalPints value stores on each iteration of the loop.

Counter

totalPints

0

34

1

73

2

Step 3: Complete the following chart by writing what the highPints and the pints array value stores on each iteration of the loop. Also conclude whether it will be True or False.

Pints

highPints

True or False

39

34

TRUE

25

39

FALSE

18

Step 4: Complete the following chart by writing what the lowPints and the pints array value stores on each iteration of the loop. Also conclude whether it will be True or False.

Pints

lowPints

True or False

39

34

FALSE

25

34

TRUE

18

25

Lab 4.3 – Arrays and Flowchart (20 pnts)

This lab requires you to create a flowchart for the blood drive program in Lab 6.1 using Raptor.

Step 1: Start Raptor and save your document as Student ID Lab 6-3. The .rap file extension will be added automatically.

Step 2: Start by adding a comment box with the necessary variables.

Step 3: Add your loop to run multiple times and your module calls in the main module.

Step 4: Add the procedure call getPints( ) in main flowchart. Use the pseudo code created in Lab 6.1 Step 2. (Hint the procedure should return an array the pints variable)

Step 5: Add the getTotal( ) procedure in the main flowchart main. Use the pseudo code created in Lab 6.1 Step 3. (Hint the procedure need an array as a parameter to perform the computation)

Step 6: Add the getAverage( ) procedure in main. Use the pseudo code in Lab 6.1 Step 4.

Step 7: Create the getHigh( ) procedure in main. Base the flowchart to pseudo code from Lab 6.1 Step 5. (Hint the procedure need an array parameter as input and return a parameter as output)

Step 8: Add the getLow( ) procedure use the develop pseudo code from Lab 6.1 Step 6.

Step 9: Create the displayInfo( ) procedure in main. The displayInfo() module should print the values of average pint collected, the higher number of pints and the lower number of pints collected.

Step 10: 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

Step 11: Paste your finished flowcharts in the space below.

PASTE FLOWCHARTS HERE

4