Question
C++ Functions w/ more than 1 argument ================================= - Write a function named conjunction, which takes two boolean inputs, and returns true if both inputs
C++
Functions w/ more than 1 argument
=================================
- Write a function named conjunction, which takes two boolean inputs, and
returns true if both inputs are true, and returns false otherwise.
- Write a function named disjunction, which takes two boolean inputs, and
returns true if one or both of the inputs are true, and returns false
otherwise.
- Write a function named allThreeTrue, which takes three boolean inputs,
And returns true if all three inputs are true, and returns false otherwise.
- Write a function named anyThreeTrue, which takes three boolean inputs,
And returns true if any of the inputs are true, and returns false otherwise.
- Write a function named allThreeFalse, which takes three boolean inputs,
And returns true if all three inputs are false, and returns false otherwise.
- Write a function named isGreaterThan, which takes two integers, and
Returns true if the first integer is greater than the second integer, and
Returns false otherwise.
- Write a function named isLessThanOrEqualTo, which takes two integers,
And returns true if the first integer is less than or equal to the second
integer, and returns false otherwise.
- Write a function named isBetweenInclusive, which takes three integer
Inputs, and returns true if the first integer is between the second and third
integer, inclusive. (inclusive means that it should return true if the first integer equals the second or third integer).
- Write a function named ifThenElse, which takes a boolean and two
integers as inputs, and returns the first integer if the boolean input is true, otherwise it returns the second integer.
- Write a function named add, which takes two integers as input and
Returns their sum as the result.
- Write a function named addAllThree, which takes three integers as input
And returns their sum as the result.
- Write a function named multiplyAllthree, which takes three integers as
input
and returns their product as the result.
- Write a function named pointsIfYes, which takes an integer and a string, and returns the integer if the isYes function you wrote earlier returns true When called with the string as an argument, and returns zero otherwise.
- Write a function named pointsIfNo, which takes an integer and a string,
and
returns the integer if the isNo function you wrote earlier returns true
when
called with the string as an argument, and returns zero otherwise.
- Write a function named scoreAnswer, which takes two strings and an
integer.
The function should return the integer if the first string equals the
second
string, otherwise return zero. The idea is that the first and second
string
represent the user's answer and the correct answer, and we only give
them
points if the user's answer equals the correct answer.
Functions That Build Strings
============================
- Write a function named exclaim, which takes a string and returns a
string
equal to the input but with an exclamation point appended to the end.
- Write a function named fullStop, which takes a string and returns a
string
equal to the input but with a period appended to the end.
- Write a function named endLine, which takes a string and returns a
string
equal to the input but with a newline (" ") appended to the end.
- Write a function named concat, which takes two strings and returns a
string
equal to the first string followed by the second string. This is called
concatenation. Example: concat("foo", "bar") == "foobar".
- Write a function named exclaimIfFoobar, which takes a string and
returns a
string equal to the input but with an exclamation point appended to the
end
ONLY if the input string equals "foobar", otherwise, simply return the
input
string.
- Write a function named appendTimes, which takes as input two strings
and an
integer. The function should return the second string appended to the
end of
the first string a number of times equal to the integer input.
Example: appendtimes("foo", "bar", 3) == "foobarbarbar".
- write a function boolToString, which takes a boolean and returns "TRUE"
if
the boolean input was true, and "FALSE" otherwise.
- write a function intToString, which takes an integer input and returns
a
string version of the number. Example: intToString(5) == "5".
NOTE: Once you get to this point in the assignment, you'll need to add
the
following header include statement to the top of your source file::
#include
You'll also need to start compiling the source file with the following
on the
command line, either before or after the source file name::
--std=c++11
And, to implement this function, you'll simply write the following::
string intToString(int a)
{
return to_string(a);
}
I gave you the answer for this one because it requires knowledge of
several
things which you haven't seen before.
- Write a function named additionToString, which takes two integers and
returns
a string that represents their addition. You must use the intToString
function to create this function.
Example: additiontoString(4, 5) == "4 + 5 = 9"
Example: additiontoString(0, 7) == "0 + 7 = 7"
- Write a function named numberQuestion, that takes an integer and a
string,
and returns a string equal to the input string with the number, a
closing
parenthesis, and a space prepended. You'll need to use intToString to
implement this function.
Example: numberQuestion(1, "First question") == "1) First question"
Example: numberQuestion(2, "Second question") == "2) Second question"
Example: numberQuestion(3, "Third question") == "3) Second question"
- Write a function named dots, which takes an integer, and returns a
string
with that many periods in it. Example: dots(5) == ".....".
- Write a function named headingLine, wich takes an integer and returns a
string with that many equal signs in it.
Example: headingLine(5) == "=====".
- Write a function named makeTitle, which takes a string input, and uses
the
headingLine function to create a "title" out of the string. A string is
converted to a title by placing a line of equal signs above and below
the
title. The lines with equal signs should contain a number of equal
signs
equal to the length of the title string.
Example: makeTitle("foo") == "=== foo ===" // Notice 3 equal signs.
Example: makeTitle("spam") == "==== spam ====" // Notice 4 equal
signs.
When sent to cout, because the result of makeTitle includes newlines,
the
title will appear on screen similar to this::
==========
Title Here
==========
To get the length of a string variable, in the following example the
variable
is named foo, you say this::
foo.length()
- Write a function named indent, which takes an integer and a string, and
prepends the string with a number of spaces (" ") equal to the integer.
Example: indent(4, "foo") == " foo"
- Write a function named repeat, which takes a string and an integer as
input,
and returns a string that is the input string appended to itself a
number of
times equal to the integer input.
Example: repeat("foo", 3) == "foofoofoo"
- Write a function named repeatLines, which takes a string and an
integer, and
uses the repeat function you just created to return a string equal to
the
input string repeated a number of times equal to the integer input, but
with
newlines between each word and one newline at the end.
Example: repeatLines("foo", 4) == "foo foo foo foo "
- Write a function named getYesOrNo, which takes no input, and asks the
user to
enter Yes or No, and continues to ask them to enter Yes or No until they
do.
Once they've entered Yes or No, return True from this function if they
entered Yes and false otherwise. Note: you must use one of the isYes or
isNo
functions that you wrote earlier.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started