Correct the code below making absolutely no changes to main

Correct the code below making absolutely no changes to main(). Instead, alter 1) prototype for calcDiscount(), definition of function calcDiscount(), and add your name into signature function. In other words, if 100.0 is entered the amount owed output should be 90.00

1488700740 03/04/2017 11:59pm

Text Entry

Keyboard ShortcutsHTML Editor Rich Content Editor

CancelUpdate Description

Additional Comments:

CancelUpdate Comments

Additional Comments:

Rubric

Can\'t change a rubric once you\'ve started using it.

Find a Rubric

Title

You\'ve already rated students with this rubric. Any major changes could affect their assessment results.

Title

I\'ll write free-form comments when assessing students

Use this rubric for assignment grading

Hide score total for assessment results

CancelCreate Rubric

Previous

Copy and paste or type your submission right here.

Keyboard ShortcutsHTML Editor Rich Content Editor

CancelSubmit Assignment

Solution

Hi

I have modified the code and highlighted the code changes below


#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: \" << \" \";
}

Output:

sh-4.2$ g++ -o main *.cpp                                                                                                                                                                                                                              

sh-4.2$ main                                                                                                                                                                                                                                                           

Enter amount owed: 100                                                                                                                                                                                                                                                 

Amount of Discount: 10.00                                                                                                                                                                                                                                              

Amount Owed: 90.00

Correct the code below making absolutely no changes to main(). Instead, alter 1) prototype for calcDiscount(), definition of function calcDiscount(), and add yo
Correct the code below making absolutely no changes to main(). Instead, alter 1) prototype for calcDiscount(), definition of function calcDiscount(), and add yo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site