Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

11. What is the value of withholding given the following function, initializatio

ID: 3572566 • Letter: 1

Question

11. What is the value of withholding given the following function, initializations, and function call?

                double withholding, grosspay = 390.00;

                int dependents = 1;

                withholding = computeWithholding(dependents, grossPay);

                double computeWithholding(int dependents, double gross)

                {

                                double withheldAmount;

                                if(dependents > 2)

                                     withheldAmount = 0.15;

                                else if (dependents == 2)

                                     withheldAmount = 0.18;

                                else if (dependents == 1)

                                     withheldAmount = 0.2;

                                else

                                     withheldAmount = 0.28

                                withheldAmount = gross * withheldAmount;

                                return (withheldAmount);

                                }

A. 390.00              B. 78.00                C. 39.00                D. 70.20

12. What does the following function return?

                double index_of_smallest(const double a[], int startindex, int numberOfSlots);

A. a double         B. the address of a double           C. an integer      D. an array of integers

13. What is the value of newChoice after the following statements?

                int choice = 0, count = 3;

                getChoice(choice,count);

                void getChoice(int& newChoice, int count)          //function definition

                {

                                if(count < 0)

                                     newChoice = 0;

                                if(count > 2)

                                     newChoice = 99;

                                else

                                     newChoice = 1;

                }

A. 3        B. 0         C. -1       D. 99

14. Which of the following is the correct way to close a file stream names outFile?

                A. outFile.closed();

                B. close;

                C. outFile.close("project.txt");

                D. close(outFile);

15. What does the following function return?

                void index_of_smallest(const double a[], int startIndex, int numberOfSlots);

A. a double         B. numberOfSlots            C. an integer      D. nothing

Explanation / Answer

11.

Actual program is :

#include <iostream>

using namespace std;
double computeWithholding(int dependents, double gross) //dependents=1  grosspay = 390.00
{
double withheldAmount;   
if(dependents > 2)
withheldAmount = 0.15;
else if (dependents == 2)
withheldAmount = 0.18;
else if (dependents == 1) // condition true
withheldAmount = 0.2;
else
withheldAmount = 0.28;
withheldAmount = gross * withheldAmount; // 390.00* 0.2 =78
return (withheldAmount); // return 78
}

int main()
{
double withholding, grosspay = 390.00;
int dependents = 1;
withholding = computeWithholding(dependents, grosspay);

// dependents = 1 and grosspay = 390.00 after operation  withholding =78
cout<<withholding; // print 78

return 0;
}

Option b is correct choice.

12.

double index_of_smallest(const double a[], int startindex, int numberOfSlots);

The function returns a double value.

Option a is correct choice.

13.

Actual program :

#include <iostream>

using namespace std;
void getChoice(int& newChoice, int count)

// newChoice = 0 and count = 3
{
if(count < 0)
newChoice = 0;
if(count > 2) // (3>2)
newChoice = 99; // newChoice value is 99
else
newChoice = 1;

cout<<newChoice; // newChoice = 99
}

int main()
{
int choice = 0, count = 3;
getChoice(choice,count); // choice = 0 and count = 3
   return 0;

}

Option D is correct choice.

14.

outFile.close(); is the correct way to close a file stream names outFile

Option A is correct choice.

15.

What does the following function return?

                void index_of_smallest(const double a[], int startIndex, int numberOfSlots);

// Since it is void it returns nothing

Option d is correct choice.

Dr Jack
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote