Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This exercise is to test ability to solve a programming problem using pseudocode. Read the problem carefully, study the pseudocode and add the missing code:

This exercise is to test ability to solve a programming problem using pseudocode.

Read the problem carefully, study the pseudocode and add the missing code:

Problem:

Consider a grade-averaging scheme in which the final average of a students scores is computed differently from the traditional average if the scores have improved. Scores have improved if each score is greater than or equal to the previous score. The final average of the scores is computed as follows.

A student has n scores indexed from 0 to n-1. If the scores have improved, only those scores with indexes greater than or equal to n/2 are averaged. If the scores have not improved, all the scores are averaged.

The following table shows several lists of scores and how they would be averaged using the scheme described above.

Student Scores Improved? Final Average 50, 50, 20, 80, 53 No (50 + 50 + 20 + 80 + 53) / 5.0 = 50.6 20, 50, 50, 53, 80 Yes (50 + 53 + 80) / 3.0 = 61.0 20, 50, 50, 80 Yes (50 + 80) / 2.0 = 65.0

Given an array named 'scores', already populated with a number of scores (as provided by property/variable 'length'), create pseudocode for the following methods/functions (use suggested variable names if provided):

(a). finalAverage: method/function uses (b) and (c) to return either average scheme as described above

(b). average: method/function returns the average of the values in scores given a starting ('first') and an ending ('last') index.

(c). hasImproved: method/function returns TRUE if the score sequence has improved (successive values in scores greater than or equal to the previous value), otherwise return FALSE

To do: Complete the function definition 'hasImproved'

Follow the general conventions of this pseudocode or use the language from this course.

------------------------------------------------------------------------------------------------------------

Proposed Pseudocdode: //finalAverage definition finalAverage input: scores as type array of int, length as type int output: type float define improved as type boolean improved = hasImproved (scores, length) if improved is TRUE then return average ( scores, length/2, length) else return average (scores, 0, length) //average definition average input: scores as type array of int, first as type int, last as type int) output: type float initialize sum as type int with value 0 loop with index starting at first and ending at last sum = sum + score[index] loop end return sum/(last - first) //hasImproved definition hasImproved input: scores as type array of int, length as type int output: type boolean // complete this pseudocode ...

//hasImproved definition hasImproved input: scores as type array of int, length as type int output: type boolean

// complete this pseudocode ...

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions

Question

5. Do you have any foreign language proficiency?

Answered: 1 week ago