Functions Worksheet #2 | Name - |
Day of Week - |
Draw the console output window with the expected output as precisely as possible.
#include <iostream>
using namespace std;
double computeDiscount(int num, double price, double rate); double computeTax(double base);
const double CLEARANCE_DISCOUNT = 0.2;
const double TAX_RATE = 0.06;
const double PRICE_PER_WIDGET = 20;
int main() { int numWidgets = 4; double basePrice = 0.0; double finalPrice = 0.0;
double discount = 0.0; basePrice = numWidgets * PRICE_PER_WIDGET; discount = computeDiscount(numWidgets, PRICE_PER_WIDGET, CLEARANCE_DISCOUNT); finalPrice = basePrice - discount; finalPrice = finalPrice + computeTax(finalPrice); cout << "The final price after discount is $" << finalPrice << endl; return 0; }// end of main
double computeDiscount(int num, double price, double rate) { return rate * num * price; }// end of computeDiscount
double computeTax(double base) { return base * TAX_RATE; }// end of computeTax