Wyo C++ - Ch. 9 Worksheet #1 Name -

1. Draw a rectangular console window in the area provided and show the expected output as precisely as possible.

#include <iostream.h>

double computeRebate(double);
double addMysteryAmount(double);

int main( )
{
      double price = 13.76;
    double finalPrice = 0.0;

   finalPrice = price - computeRebate(price);

   cout << finalPrice << endl;

   return 0;
}

double computeRebate(double initial)
{
   double final = 0.0;

   final = initial * 0.20;
   final = addMysteryAmount(final);

   return final;
}

double addMysteryAmount(double price)
{
   double withExtra = 0.0;

   withExtra = price + 0.05 * price;

   return withExtra;
}

   

2. Draw a rectangular console window in the area provided and show the expected output as precisely as possible.

#include <iostream.h>

int addAFew(int);
void displayNum(int);

int main( )
{
    int number = 10;

    while (number < 50)
    {
        number =addAFew( number);
    }


   displayNum(number);
  
   return 0;
}

int addAFew(int base)
{
    return (base + 5);
}

void displayNum(int aNumber)
{
    cout << "The number is " << aNumber << endl;
}

3. Write a program that includes a function named computeTax. The program prompts the user to input the price of a candy bar (a floating-point value). The function computeTax should compute the amount of 6% PA state sales tax on the candy bar. The program (not the function) should then display the final cost rounded to the nearest penny.