.

Wednesday, February 27, 2019

It 210 Week 4 Check Point 1

1 Decl are CountAge As Integer 2 Declare SumAge As Float 3 Declare Age As Float 4 Declare ParticipantAverold age As Float 5 tidy sum CountAge 0 6 Set SumAge 0 7 Write put down one age. enroll 0 when done. 8 Input Age 9 slice Age 0 10 Set CountAge = CountAge + 1 11 Set SumAge = SumAge + Age 12 Write Enter an instrumentalist age. Enter 0 when done. 13 Input Age 14 End While 15 Set ParticipantAverage = SumAge / CountAge 16 Write Your age average is + AgeAverage * Lines 16 declare and initialize the variables. Line 7 asks for the first age and also explains that when you are finished entering the age for a busy set, you fag end by entering 0. * The first Age is input on line 8. * Lines 914 are the loop. It sums the age entered and it keeps appear of how many ages were entered. * In Line 10 keeps give chase of how many ages are entered. For each pass through the loop, CountAge is incremented by 1. If you enter three ages forrader you end the program by entering 0, the loo p will follow out three times and CountAge will be equal to 3.If you enter 5 ages, the loop will execute 5 times and CountAge will be equal to 5. * Line 11 keeps a sum of every the participant ages. To compute your participant average age, you must divide the sum of all your participants ages by the number of participants, so lines 10 and 11 keep track of the information we need to compute the average at the end. * Lines 12 and 13 ask the user for the next participants age and gets the next input. Here, if youre done, you can enter a 0. * Line 14 ends the loop when the user enters a zero. * Line 15 computes the average and line 16 displays that average.

No comments:

Post a Comment