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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education