Using C++. (Please correct the code as indicated below. Thank you!) Correct the code below making absolutely no changes to main(). Instead, alter 1) prototype for calcDiscount(), 2) alter definition of function calcDiscount(), 3) change Pre comment in calcDiscount as appropriate, and 4) add your name into signature function.  Test your code 100.0 entered; the amount of discount output should be 10.00 and amount owed output should be 90.00. /************************************************************* ****Change only 1) function calcDiscount, 2) its prototype *** ****and 3) change Pre comment in calcDiscount as appropriate, *** *** and 4) add your name into signature function!************* **************************************************************/ #include #include using namespace std; #define DISC_RATE 0.1 //Function prototypes void signature(void); double calcDiscount(double); int main() { // Declare variaables double amtOwing, discount; //Input amouont owed cout << "Enter amount owed: " ; cin >> amtOwing; //Calculate discount and update amount owing discount = calcDiscount(amtOwing); //Output discount and undated amount owed cout << setprecision(2) << fixed; cout << "Amount of Discount: " << discount << endl; cout << "Amount Owed: " << amtOwing << endl; signature(); return 0; } /////////////////////////////////////////////////////////////// double calcDiscount(double owe) { /*Pre: owe - amount owed Post: Amount of discount Purpose: calculate discount and update amount owed to reflect discount*/ double disc; disc = DISC_RATE * owe; //Update amount owed owe = owe - disc; return disc; }////////////////////////////////////////////////////////// void signature() { cout << "Programmed by: " << " "; }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter6: User-defined Functions
Section: Chapter Questions
Problem 18SA
icon
Related questions
Question

 

Note: Using C++. (Please correct the code as indicated below. Thank you!)

Correct the code below making absolutely no changes to main(). Instead, alter 1) prototype for calcDiscount(), 2) alter definition of function calcDiscount(), 3) change Pre comment in calcDiscount as appropriate, and 4) add your name into signature function. 

Test your code 100.0 entered; the amount of discount output should be 10.00 and amount owed output should be 90.00.

/*************************************************************
****Change only 1) function calcDiscount, 2) its prototype ***
****and 3) change Pre comment in calcDiscount as appropriate, ***
*** and 4) add your name into signature function!*************
**************************************************************/

#include <iostream>
#include <iomanip>
using namespace std;
#define DISC_RATE 0.1

//Function prototypes
void signature(void);
double calcDiscount(double);

int main()
{
// Declare variaables
double amtOwing, discount;

//Input amouont owed
cout << "Enter amount owed: " ;
cin >> amtOwing;

//Calculate discount and update amount owing
discount = calcDiscount(amtOwing);

//Output discount and undated amount owed
cout << setprecision(2) << fixed;
cout << "Amount of Discount: " << discount << endl;
cout << "Amount Owed: " << amtOwing << endl;

signature();
return 0;
}
///////////////////////////////////////////////////////////////
double calcDiscount(double owe)
{
/*Pre: owe - amount owed
Post: Amount of discount
Purpose: calculate discount and update amount owed to reflect discount*/

double disc;
disc = DISC_RATE * owe;
//Update amount owed
owe = owe - disc;

return disc;
}//////////////////////////////////////////////////////////
void signature()
{
cout << "Programmed by: " << " ";
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Events
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning