Question

C++ Instructions Write a program to test the functions described in Exercises 11 and _14_ of...

C++

Instructions

Write a program to test the functions described in Exercises 11 and _14_ of this chapter.

Instructions for Exercise 11 and Exercise 14 have been posted below for your convenience.

EXERCISE 11

Write the definition of a function that takes as input a char value, and returns true if the character is a whitespace character; otherwise it returns false.

If the character is a whitespace character ouput the following message: The character you entered is a whitespace character, othersise output: The character you eneted is not a whitespace character

EXERCISE 14

Write the definition of a function that takes as input three numbers. The function returns trueif the floor of the product of the first two numbers equals the floor of the third number; otherwise it returns false. (Assume that the three numbers are of type double.) Output the appropriate message:The product of the first two numbers is not equal to the floor of the third number

or

The product of the first two numbers is equal to the floor of the third number

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Explanation::

  • Code in C++ is given below.
  • Please read comments for better understanding of the code.
  • Screenshots of the code are given at the end of the code.

CODE IN C++ ::

#include<iostream>
#include<string>
#include<cmath>
using namespace std;
bool isWhiteSpace(char c);
bool floorCheck(double a,double b,double c);
int main(){
/***
* Calling function isWhiteSpace()
* A char variable named ch is declared below and
* I have used string to take input from user and then assign char at
* index 0 to char variable ch.
*/
string str;
char ch;
cout<<"PART A :: EXERCISE 11\n"<<endl;
cout<<"Enter any char ::";
getline(cin,str);
ch=str[0];
if(isWhiteSpace(ch)){
cout<<"The character you entered is a whitespace character\n"<<endl;
}else{
cout<<"The character you entered is not a whitespace character\n"<<endl;
}
cout<<"\n_______________PART A ENDS_______________\n\n"<<endl;

/***
* Calling function floorCheck()
*
* Three double values are declared named a,b and c
*/
double a,b,c;
cout<<"PART B :: EXERCISE 14\n"<<endl;
cout<<"Enter 1'st double value ::";
cin>>a;

cout<<"Enter 2'nd double value ::";
cin>>b;

cout<<"Enter 3'rd double value ::";
cin>>c;
if(floorCheck(a,b,c)){
cout<<"\nThe product of the first two numbers is equal to the floor of the third number\n"<<endl;
}else{
cout<<"\nThe product of the first two numbers is not equal to the floor of the third number\n"<<endl;
}
cout<<"_______________PART B ENDS_______________\n"<<endl;

return 0;
}
bool isWhiteSpace(char ch){
/**
* If char ch is a whitespace then ch==' ' will be true and so
* true will be returned.
* Else false will be returned.
*/
return ch==' ';
}
bool floorCheck(double a,double b,double c){
/**
* This function returns true if following condition is true.
* I.e floor(a*b) is equal to floor(c),
* else it will return false.
*/
return floor(a*b)==floor(c);
}

OUTPUT::

TEST CASE 1::

TEST CASE 2::

Please provide the feedback!!

Thank You!!

Add a comment
Know the answer?
Add Answer to:
C++ Instructions Write a program to test the functions described in Exercises 11 and _14_ of...
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
  • Write the definition of a function that takes as input the three numbers. The function returns...

    Write the definition of a function that takes as input the three numbers. The function returns turn if the first number to the power of the second number equals the third number otherwise it returns false. Assume that the three numbers are of type double. Use paw() function for the power.

  • String Processing Labs Directions: Write a main program to test the three functions described below, Input...

    String Processing Labs Directions: Write a main program to test the three functions described below, Input is from a file, and output is to a file. 1. The function Another parameter is a char variable with a letter value. The function outputs the number of times the char value appears in the string. processes a string containing letters of the alphabet, which is a parameter 2. This Boolean function has two string parameters. It returns true when the first str...

  • c++ language Write a program that contains the following functions, i. A function isVowel that takes...

    c++ language Write a program that contains the following functions, i. A function isVowel that takes in a character and returns true if it is a vowel and false otherwise ii. A function that request from the user to enter in a sequence of characters, and outputs the number of vowels entered. (Use Function in a) to assist you, a sentinel value can be used to specify the end of the user input iii. A function that reads 3 test...

  • c++ #include <iostream> #include <string> using namespace std; /* Write a function checkPrime such that input:...

    c++ #include <iostream> #include <string> using namespace std; /* Write a function checkPrime such that input: an int output: boolean function: Return true if the number is a prime number and return false otherwise */ //TO DO ************************************** /* Write a function checkPrime such that input: an array of int and size of array output: nothing function: Display the prime numbers of the array */ //TO DO ************************************** /* Write a function SumofPrimes such that input: an int output: nothing...

  • Write a C++ program that does the following : 1. Accepts array size from the keyboard....

    Write a C++ program that does the following : 1. Accepts array size from the keyboard. The size must be positive integer that is >= 5 and <= 15 inclusive . 2. Use the size from step 1 in order to create an integer array. Populate the created array with random integer values between 10 and 200. 3. Display the generated array. 4. Write a recursive function that displays the array in reverse order . 5. Write a recursive function...

  • *Please write in code in C* First, write a function called prime_check(int x) that takes an...

    *Please write in code in C* First, write a function called prime_check(int x) that takes an integer number as an input then return 1 if it is a prime number nd returns 0 if it is a composite number Then, Write a program that prompt the user to input two numbers: Print the multiplication of these two numbers if both of them are prime. Or Print " Sorry at least one of your number is composite" if otherwise

  • CENGAGE MINDTAP Programming Exercise 4-8 Instructions Instructions Write a program that mimics a calculator. The program...

    CENGAGE MINDTAP Programming Exercise 4-8 Instructions Instructions Write a program that mimics a calculator. The program should take as input: 1. The first integer 2. The second integer 16 3. The operation to be 11 performed ( + . 12 13 ess 14 It should then output the 15 numbers, the operator, and the er 16 result. (For division, if the 17 c denominator is zero, output an 18 19 ( appropriate message. The 20 message should contain the word...

  • Please Use C++ for coding . . Note: The order that these functions are listed, do...

    Please Use C++ for coding . . Note: The order that these functions are listed, do not reflect the order that they should be called. Your program must be fully functional. Submit all.cpp, input and output files for grading. Write a complete program that uses the functions listed below. Except for the printodd function, main should print the results after each function call to a file. Be sure to declare all necessary variables to properly call each function. Pay attention...

  • Use C programming Make sure everything works well only upload Write a program that takes an...

    Use C programming Make sure everything works well only upload Write a program that takes an integer from standard input and prints all prime numbers that are smaller than it to standard output. Recall that a prime number is a natural number greater than 1 whose only positive divisors are 1 and itself. At the start of the program, prompt the user to input a number by printing "Input a number greater than 2:\n". If the user's input is less...

  • In C++ Programming Write a program in a file named SeedFinder.cpp that finds and displays all...

    In C++ Programming Write a program in a file named SeedFinder.cpp that finds and displays all the seeds of a integer given by the user. Let’s define a seed of an integer, n, to be a positive value that equals n when multiplied by its individual digits. For example, 23 is a seed of 138 because 23 × 2 × 3 = 138. 111 is an example of a seed of itself because 111 × 1 × 1 × 1...

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
Active Questions
ADVERTISEMENT