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

Exercise 2. Change your program so that when the number ofdollar signs is odd, i

ID: 3614760 • Letter: E

Question

Exercise 2. Change your program so that when the number ofdollar signs is odd, it uses:

(numSigns + 1) / 2 - 2

at the inside height dimension.


Writing boxes on the screen is fun. Program Shell2is the shell of a program that prompts the user to enter andinteger number. When completed this number is read and passed tofunction Print as parameternumSigns. The function prints a box ofdollar signs on the screen that is numSigns by(numSigns / 2). For example, ifnumSigns is 10, the following box is printed onthe screen.

$$$$$$$$$$
$               $
$               $
$               $
$$$$$$$$$$

Note the interior dimensions are (numSigns-2) x(numSigns / 2-2).



// Program Shell2 prompts for the number of dollar signs for
// the top of the box. That number / 2-2 lines are
// printed with dollar signs on the sides.

#include <iostream.h>

void Print(int numSigns);
// Fill in documentation.

int main ( )
{
     int number;

     cout << "Enter the number of dollarsigns for the top; "
           << "press return."
     cout << "Enter end-of-file characterto quit." << endl;
     cin >> number;
     while(cin)
     {
          /* FILL INcall to Print */
         cout <<"Enter the number of dollar signs for "
               << "the top; press return. "
         cout <<"Enter end-of-file character to quit."
               << endl;
         cin >>number;
       }
       return 0;
}




// *********************************************

void Print(int numSigns)
// Fill in documentation.

{
      /* FILL IN code to print numSigns$'s                    */

     /* FILL IN code to print (numSigns / 2)-2lines with */
   /* $'s lining up under the left-most andright-most      */
   /* $ ones on the topline.                                         */

     /* FILL IN code to print numSigns$'s                    */
}

Explanation / Answer

please rate - thanks // Program Shell2 prompts for the number of dollar signs for // the top of the box. That number / 2-2 lines are // printed with dollar signs on the sides. #include void Print(int numSigns); // Fill in documentation. int main ( ) {      int number;      cout