1. Write the definition of a function that evaluates three doublenumbers and returns trueif the floor of the product of the first two numbers equals the floor of the third number; otherwise it returns false. a.The precondition for this function is that the input to the function consists of three double numbers. The postcondition is that it returns a Booleanvalue that is true if the floor of the product of the first two numbersis equal to the floor of the third, otherwise the function returns false. b.The input into the function is passed by value, the calculations are performed and evaluated inside the function, and the functionreturnstrue or false (a boolvalue). c.The caller of this function is expected to supply the input values and output a message to the display describing the results (i.e., “The floor of the product of the first two numbers is equal to the floor of the third number” or “The floor of the product of the first two numbers is NOT equal to the floor of the third”). d. In your program, provide the prototype for this function and comments documenting the preconditions and postconditions (either before or after the prototype). e. Place the function definition after the main function. 2. Write the definition of a function that calculates the sum and average of the numbers in an interval.

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

1. Write the definition of a function that evaluates three doublenumbers and returns trueif the floor of the product of the first two numbers equals the floor of the third number; otherwise it returns false.

a.The precondition for this function is that the input to the function consists of three double numbers. The postcondition is that it returns a Booleanvalue that is true if the floor of the product of the first two numbersis equal to the floor of the third, otherwise the function returns false.

b.The input into the function is passed by value, the calculations are performed and evaluated inside the function, and the functionreturnstrue or false (a boolvalue).

c.The caller of this function is expected to supply the input values and output a message to the display describing the results (i.e., “The floor of the product of the first two numbers is equal to the floor of the third number” or “The floor of the product of the first two numbers is NOT equal to the floor of the third”).

d. In your program, provide the prototype for this function and comments documenting the preconditions and postconditions (either before or after the prototype).

e. Place the function definition after the main function.

2. Write the definition of a function that calculates the sum and average of the numbers in an interval.

a.The preconditionsarethat the input to the function is two integer values and that the first number is less than the second number.

i. Make sure to provide code inside the function that ensures the preconditions are met. For example, if the end points of the interval are passed in the wrong order, your code would need to adjust them.

b.The postcondition is that the sum of the numbers in the interval and the average of the numbers in the interval is returned. Since a function can only return a single result, your function would be declared as a voidfunction and the results would be returned through reference parameters that are declared in the caller.

i. Notice that the postcondition does not say anything about displaying these values. The caller of the function decides what to do with the values after the function calculates them.

c. In your program, provide the prototype for this function and comments documenting the preconditions and postconditions (either before or after the prototype).

d. Place the function definition after the main function.

3.Write a driver to test your functions.

a. A driver is a main function that is written to implement the test plan for the functions you have written.

i. Contrast a driver with an application (a main function written to solve a real-world problem).

b. When writing a driver, it is not necessary to ask for user input. Instead, assign the input values from your test plan to the input parameters for the function you are testing, call the function, and then evaluate the output to see if the postconditions have been met (the output part of your test plan). This may involve multiple calls to your function in the driver with different inputs.

C++

Expert Solution
Introduction

The give is the problem to be solved in C++ language where a program having a main method and user defined method is to be added for making certain checks and return the result as a boolean value from user defined function to calling main method.

 

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Algebraic Expression
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
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