Question

C++ Write a function sleepIn with two parameters 'weekday' and 'vacation'. The parameter 'weekday' is True...

C++

Write a function sleepIn with two parameters 'weekday' and 'vacation'.

The parameter 'weekday' is True if it is a weekday, and the parameter 'vacation' is True if we are on vacation.

We sleep in if it is not a weekday or we're on vacation. Return True if we can sleep in.

function prototype: bool sleepIn(bool weekday, bool vacation):

Function Call Function Returns
sleepIn(false, false); true OK     
sleepIn(true, false); false OK     
sleepIn(false, true); true OK     
sleepIn(true, true); true OK     
0 0
Add a comment Improve this question Transcribed image text
Answer #1
bool sleepIn(bool weekday, bool vacation){
    if(!weekday || vacation){
        return true;
    }
    else{
        return false;
    }
}


Add a comment
Know the answer?
Add Answer to:
C++ Write a function sleepIn with two parameters 'weekday' and 'vacation'. The parameter 'weekday' is True...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use c++ programming environment to implement and test a function with the following prototype: //the parameter...

    Use c++ programming environment to implement and test a function with the following prototype: //the parameter month and day should represent a valid date //return true if the date is between 3/8 and 10/31; false otherwise bool is_daylight(int month, int day); Following TDD (test-driven development), it is important to know the expected return values for different function calls. Function call Expected return Function call Expected return is_daylight(2, 20) false is_daylight(3, 7) false is_daylight(4, 1) true is_daylight(10, 31) true is_daylight(11, 1)...

  • Result inト 9c. (5 pts) Write a function named between that is defined with two parameters. It re...

    in python result inト 9c. (5 pts) Write a function named between that is defined with two parameters. It returns a reference to a tion that has one parameter, which returns whether or not its one parameter is between (inclusive) the two arguments supplied when between is called. For example x between (18,22) and the call x(29) returns True. def between(lower, upper): result inト 9c. (5 pts) Write a function named between that is defined with two parameters. It returns...

  • Write a C++ function that has a parameter of char type. The function returns true if...

    Write a C++ function that has a parameter of char type. The function returns true if the character is ‘Y’ or ‘y’, and returns false if the character is ‘N’ or ‘n’. You are not allowed to use any pre-defined function.

  • COSC 112 Test #3 Spring 2019 20. It is not necessary to specify the parameter name...

    COSC 112 Test #3 Spring 2019 20. It is not necessary to specify the parameter name in the parameter list of a function prototype even 21. Which of following is not a situation when reference parameters are useful? though there is a default parameter. (True/False) a. When you don't want to have side effects b. When you need to change the actual parameter c. When you need to return more than one value d. When you want to save memory...

  • In C++, write a function isOdd() that takes one integer parameter. The function returns true if...

    In C++, write a function isOdd() that takes one integer parameter. The function returns true if the number if odd and false otherwise.

  • Write a recursive function (C++) that searches a binary tree that is NOT ordered like a...

    Write a recursive function (C++) that searches a binary tree that is NOT ordered like a BST. In other words, there is no ordering relationship among the parent, child or sibling node values. Use the following prototype and data structure: struct node { node *left; node *right; int val; }; // First parameter: pointer to a node // Second parameter: the value to find bool searchValue(node *, int); The function searchValue() should return true if the integer value in the...

  • Need help problem 9-13 C++ Homework please help WRITE FUNCTION PROTOTYPES for the following functions. The...

    Need help problem 9-13 C++ Homework please help WRITE FUNCTION PROTOTYPES for the following functions. The functions are described below on page 2. (Just write the prototypes) When necessary, use the variables declared below in maino. mm 1.) showMenu m2.) getChoice 3.) calcResult m.) showResult 5.) getInfo mm.) showName 7.) calcSquare 8.) ispositive int main { USE THESE VARIABLES, when needed, to write function prototypes (#1 - #8) double num1 = 1.5; double num2 = 2.5; char choice; double result;...

  • We want to write a function called sortTwo that takes two integer parameters, and after the...

    We want to write a function called sortTwo that takes two integer parameters, and after the function is called the first parameter is the smaller of the two values, and the second parameter is the larger of the two values. In other words, this is a miniature sorting function. For this problem you must supply the missing code for PARTs 1, 2, and 3 in the program below. // PART 1: function prototype int main ( ) { int x,y;...

  • help ASAP 3. Write a string C++ function named UnsignedPartialSum() that takes two string parameters and...

    help ASAP 3. Write a string C++ function named UnsignedPartialSum() that takes two string parameters and an int parameter. If both string parameters represent binary numbers and the int parameter is equal to a positive number less than or equal to the length of the longest string parameter, the function should return a binary string whose length is equal to two times the length of the maximum length of the two string parameters whose value is equal to the sum...

  • Create a JavaScript function named display_data that has two parameters. The first parameter will be a...

    Create a JavaScript function named display_data that has two parameters. The first parameter will be a String containing a JSON blob like the function in part 1 returns. The second parameter will be a boolean. Start by using the JSON library to convert the first parameter into a usable JavaScript Object. Next get the HTML element whose id is "data". This HTML element is a div. If the second parameter is equal to true ​, write the value associated with...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT