1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zysi [14]
3 years ago
12

Assume you need to test a function named inOrder. The function inOrder receives three int arguments and returns true if and only

if the arguments are in non-decreasing order: that is, the second argument is not less than the first and the third is not less than the second. Write the definition of driver function testInOrder whose job it is to determine whether inOrder is correct. So testInOrder returns true if inOrder is correct and returns false otherwise. . For the purposes of this exercise, assume inOrder is an expensive function call, so call it as few times as possible!
Computers and Technology
1 answer:
Karo-lina-s [1.5K]3 years ago
8 0

Answer:

  1. def testInOrder(a1, a2, a3):
  2.    aList = [a1, a2, a3]
  3.    if(min(aList) != a1 ):
  4.        return False  
  5.    
  6.    if(max(aList) != a3):
  7.        return False  
  8.    
  9.    return True  
  10. def inOrder(n1, n2, n3):
  11.    print(testInOrder(n1, n2, n3))
  12. inOrder(2, 4, 5)
  13. inOrder(4, 3, 6)
  14. inOrder(4, 3, 2)
  15. inOrder(3, 5, 1)

Explanation:

Firstly we create a driver function testInOrder that takes 3 inputs, a1, a2, and a3 (Line 1).

Since the value of a1 to a3 must be in ascending order so we can check if the a1 and a3 are the minimum and maximum number among the three, respectively. To do so, put a1, a2 and a3 into a list (Line 2). Next, we can use the min function to check if the minimum number is a1 (Line 3). If not return False (Line 4).

We can use the similar way to check if the maximum number of list is a3. If not return False (Line 6-7).

If both of the if conditions are not met, return True (Line 9).

We can test our driver function by repeatedly call the inOrder function with different sets of arguments (Line 14 - 17). We shall get the output as follows:

True

False

False

False

You might be interested in
A network with 6 bits remaining for the host portion will have how many usable hosts?​
Readme [11.4K]
<span>A network with 6 bits remaining for the host portion will have 62 usable hosts. The netmask is </span><span>255.255.255.192/26, the shorthand is [6-bit] which is equal to the number of addresses as <span>= 62 hosts + 1 bcast + 1 net base</span></span>
6 0
3 years ago
Which description best applies to a macro?
Mama L [17]

A macro is that pseudo-program that performs a list of actions based on a set of instructions.

<h3>What is macro?</h3>

A macro can be said to be a number of commands that help you to get complex things done via automating simple and via repetitive tasks.

A macro is that pseudo-program that performs a list of actions based on a set of instructions.

Therefore, option A is correct as the macros does a whole lot of work.

Learn more about macro from

brainly.com/question/20050035

#SPJ1

6 0
2 years ago
Could someone please help me with this?
Alexxandr [17]

Answer:

See explanation

Explanation:

Given

if(fish > 400) {

Required

What is the condition checking?

The above statement is an if conditional statement. Analysing the statement in bits:

if -> This represents the beginning of the conditional statement

fish -.> The variable that is being checked

> 400 -> The condition which the variable is being measured by.

So, the statement above is checking if the value of variable fish is greater than 400.

<em>If the condition is true, the instructions associated to that if statement will be executed.</em>

7 0
3 years ago
How can you troubleshoot Internet access problems?
joja [24]

Answer:

Check the network icon (or wireless connection settings) to see if you have Internet access. ...

Check for changes to proxy settings.

Check the network cables if your computer is wired to the router.

Reset your router.

Check your firewall or security software.

Hopefully this helps.

8 0
3 years ago
An employee’s total weekly pay equals the hourly wage multiplied by the total number of regular hours plus any overtime pay. Ove
Feliz [49]

Answer:

C++ programming language is used to implement this program using Dev C++. You can use any C++ compiler to run this program. The code and its explanation is given below in explanation section.

Explanation:

#include<iostream>

using namespace std;

int main()

{

int totalWeeklyPay;//total weekly pay  

int hourlyWage;// wages per hours

 

int totalRegularHour;// total regular hours worked

int totalOverTimeHour;// total over time hours worked

 

int weeklyTotalRegularPay;

int weeklyTotalOverTimePay;

 

cout<<"Enter Wage per hour: ";

 cin>>hourlyWage;

 if (hourlyWage<0)//if use enter negative value

  {

   cout<<"Please enter positive number number for wage per hour\n";

   cout<<"Enter Wage per hour: ";

     cin>>hourlyWage;

  }

cout<<"Enter total regular hour: ";

cin>>totalRegularHour;

if (totalRegularHour<0)//if user enter negative value

  {

   cout<<"Please enter positive total number of regular hour\n";

  cout<<"Enter total regular hour: ";

     cin>>totalRegularHour;

  }

cout<<"Enter total over time hour: ";

cin>>totalOverTimeHour;

 

 if(totalOverTimeHour<0)//if user enter negative value

   {

    cout<<"Please enter positive total number of over time hour\n";

  cout<<"Enter total over time hour: ";

  cin>>totalOverTimeHour;

     

     

 }

 

weeklyTotalRegularPay =hourlyWage*totalRegularHour;// total weekly regular hour pay

weeklyTotalOverTimePay=totalOverTimeHour*hourlyWage*1.5;// total weekly overtime pay

totalWeeklyPay=weeklyTotalRegularPay + weeklyTotalOverTimePay;//total weekly regular hour pay + // total weekly overtime pay

cout<<"Total Weekly Pay is: "<<totalWeeklyPay<<"$";//output

 

 

return 0;

 

}

3 0
3 years ago
Other questions:
  • Jannette has been experiencing slow performance on her computer. Today she received an error message saying that an update to he
    12·2 answers
  • A computer-aided system for the collection, storage, retrieval, analysis, and presentation of spatial data of all kinds is calle
    7·1 answer
  • A job posting is the best way to find out what _____ are required for a position.A.aptitudes B.hard skills C.soft skills D.dress
    10·2 answers
  • .The process of capturing the requirements includes all ofthe following with the exception of:
    10·1 answer
  • A model release can be either oral or written down. true or false
    11·2 answers
  • Assuming that t is an array and tPtr is a pointer to that array, which expression refers to the address of element 3 of the arra
    7·1 answer
  • When activated, an Excel object has all the features of an Excel ______?
    9·2 answers
  • A town decides to publicize data it has collected about electricity usage around the city. The data is freely available for all
    9·1 answer
  • What does the Finder do?
    5·1 answer
  • where element is the Hypertext Markup Language (HTML) element and _____ pairs define the styles that are applied directly to tha
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!