The Palmertown Elementary School has 30 classrooms The child

The Palmertown Elementary School has 30 classrooms. The children in the school donate used books to sell at an annual fundraising book fair. Write a program in pseudocode that accepts each teacher’s name and the number of books donated by that teacher’s classroom. Display the names of the four teachers whose classrooms donated the most books.

b. Modify the book donation program so that, besides the teacher’s name and number of books donated, the program also accepts the number of students in each classroom. Display the names of the teachers whose classrooms had the four highest ratios of book donations per pupil. and calculate all of the ratios of book donations per student first in another parallel array and then work on finding the four highest of those ratios.

Here what I have so far, please correct me if i have anything wrong. Thanks

start

                Declarations

                                num SIZE = 30

                                num DISPLAY = 4 string names[SIZE]

                                num numBooks

                                num numStudents

                                num ratios[SIZE]

                                string didSwap

                                num x

                                num tempRatio

                                string tempName

                                num comparisons

x = 0

output “Enter a teacher’s name”

input names[x]

output “Enter the number of books donated”

input numBooks

output “Enter the number of students”

input numStudents ratios[x] = numBooks/numStudents

x = x + 1

while x < SIZE

output “Enter a teacher’s name”

input names

output “Enter the number of books donated”

input numBooks

output “Enter the number of students”

input numStudents ratios[x] = numBooks/numStudents x = x + 1

endwhile

comparisons = SIZE - 1

Solution

In declarations, there seems to be no use of didSwap, tempRatio, tempName and comparisons.

Then, why did you run one iteration to take input outside the while loop?

Also, use for loop in cases where you are definitive about the time it will take for the loop to end. This way you will avoid errors.

Also, I\'ll add the pseudocode to get maximum ratios.

Final Pseudocode:

Declarations

num SIZE = 30

num DISPLAY = 4

string names[SIZE]

num numBooks

num numStudents

num ratios[SIZE]

num x

for x = 0; x<SIZE; x++

output “Enter a teacher’s name”

input names[x]

output “Enter the number of books donated”

input numBooks

output “Enter the number of students”

input numStudents

ratios[x] = numBooks/numStudents

endfor

num max = 0

num maxIndex = -1

output \"Four highest ratios\"

for i = 0; i<4; i++

    for x = 0; x<30; x++

        if ratios[x]>max:

            maxIndex = x

            max = ratios[x]

        endif

    endfor

    output max

    ratios[maxIndex]=0

    maxIndex = -1

    max = 0

endfor

The Palmertown Elementary School has 30 classrooms. The children in the school donate used books to sell at an annual fundraising book fair. Write a program in
The Palmertown Elementary School has 30 classrooms. The children in the school donate used books to sell at an annual fundraising book fair. Write a program in
The Palmertown Elementary School has 30 classrooms. The children in the school donate used books to sell at an annual fundraising book fair. Write a program in

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site