18. The mean of a set of numbers is the average computed by dividing the sum of the numbers by the quantity of the numbers. Complete method getMean below. // precondition: // postcondition: public static double getMean(int[] list) list is a non-empty array of integers. getMean returns the mean of the integers stored by list.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Array Concepts
Section: Chapter Questions
Problem 19RQ
icon
Related questions
Question
18. The mean of a set of numbers is the average computed by dividing the sum of the numbers by the quantity of the
numbers. Complete method getMean below.
// precondition:
// postcondition:
list is a non-empty array of integers.
getMean returns the mean of the integers stored by list.
public static double getMean(int[] list)
{
Transcribed Image Text:18. The mean of a set of numbers is the average computed by dividing the sum of the numbers by the quantity of the numbers. Complete method getMean below. // precondition: // postcondition: list is a non-empty array of integers. getMean returns the mean of the integers stored by list. public static double getMean(int[] list) {
Expert Solution
Step 1

Introduction

Pre-Condition:

A precondition is a requirement or condition that must be satisfied before a certain function, method, or algorithm can be executed. It is a statement about the state of the system or input that must be true in order for the function to work as intended.

In software development, preconditions are used to ensure that the input to a function or method is valid and meets the expected requirements. If the preconditions are not met, the function may produce incorrect or unpredictable results.

For example, in the getMean method that was defined in the previous question, the precondition is that the input list array must be a non-empty array of integers. This means that the function expects the input to be a valid array with at least one element, and all elements must be integers. If the input does not meet these requirements, the function may produce unexpected results or throw an error.

Post-Condition:

A postcondition is a statement about the system's state or output that is guaranteed to be true after a certain function, method, or algorithm has been executed. It describes the desired or expected results of the function.

In software development, postconditions are used to specify what the function should produce as output, and to define the conditions that must be met for the output to be considered valid. The postcondition defines the desired properties of the output and can be used to validate the results of the function or to check for errors.

For example, in the getMean the method defined earlier, the postcondition is that the function returns the mean of the integers stored in the list array. This means that after the function has been executed, it should return the average value of all the integers in the list array. The postcondition defines what the function should produce as output, and can be used to validate the results or to check for errors.

 
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning