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...

  • 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...

  • 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.

  • 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...

  • 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.

  • 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;...

  • 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...

  • Write a function to check if a number is multiple of 3 The function name is...

    Write a function to check if a number is multiple of 3 The function name is isMultipleOf3 The function returns a Bool value The function takes one integer argument The function will check if the number passed in is a multiple of 3. If it is multiple of 3, return true, otherwise return false A number is multiple of 3 if it can be divided by 3 evenly, such as 3, 30, 15, 21, etc. You only need to write...

  • write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy....

    write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy. The function should be passed 2 parameters, as illustrated in the prototype below. int pow_xy(int *xptr, int y); Assuming that xptr contains the address of variable x, pow_xy should compute x to the y power, and store the result as the new value of x. The function should also return the result. Do not use the built-in C function pow. For the remaining problems,...

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
ADVERTISEMENT