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 name[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

endwhile

                comparisons = SIZE - 1

                x = 0

                didSwap = “Yes”

                while didSwap = “Yes”

                                x = 0

                                didSwap = “No”

                while x < comparisons

                                if ratios[x] < ratios[x + 1] then

                                didSwap = “Yes”

                endif

                endwhile

                return

                x = x + 1

                tempRatio = ratios[x+1]

                ratios[x+1] = ratios[x]

                ratios[x] = tempRatio

                tempName = names[x+1]

                names[x+1] = names[x]

                names[x] = tempName

                return

                x = 0

                while x < DISPLAY

                output names[x]

                x = x + 1

                endwhile

                return

stop

Solution

Answer:

I have looked into our code; your code needs some modification. So I modified your code.

Modified code:

start

Declarations

                           num SIZE = 30

                              num DISPLAY = 4

                              string names[SIZE]

                              num numBooks

                              num numStudents

                              num ratios[SIZE]                               

                              num x

                             num y                            

                              num tempRatio

                              string tempName

                              num comparisons

                x = 0               

                while x < SIZE

                   output “Enter a teacher’s name”

                   input name[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

               endwhile

               comparisons = SIZE - 1

               x = 0  

               y = 0            

               while x < comparisons

                   y=0

                   while y < comparisons

                        if ratios[y] < ratios[y + 1] then

                                tempRatio = ratios[y+1]

                                  ratios[y+1] = ratios[y]

                                  ratios[y] = tempRatio

                                  tempName = names[y+1]

                                  names[y+1] = names[y]

                                  names[y] = tempName

                        endif

                        y = y+1

                   endwhile

                    x = x+1

               endwhile               

               x = 0

               while x < DISPLAY

                   output names[x]

               x = x + 1

               endwhile               

stop

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
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