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

*Please utilize C++ format when answering questions 45. a) Write a function that

ID: 3626486 • Letter: #

Question

*Please utilize C++ format when answering questions

45. a) Write a function that calculates the new price of an item on sale. The sale price is some percentage off or some amount off, whichever calculates the larger sale price. Your function should take the price, the percentage amount, and the dollar off amount. If should calculate and return the sale price. For example, if the price was $25 and it was on sale for either 20% off or $10 off, the new sale price would be $20.

b) Write a function call for the function you just defined. Declare, and initialize if needed,any variables you need to make this function call.

Explanation / Answer

please rate - thanks

#include <iostream>
#include <iomanip>
using namespace std;
double getNew(double,double,double);
int main()
{double price,percent,amt;
cout<<"Enter original price: ";
cin>>price;
cout<<"Enter percent off: ";
cin>>percent;
cout<<"enter amount off: ";
cin>>amt;
cout<<"The new price is $"<<setprecision(2)<<fixed<<getNew(price,percent,amt)<<endl;
system("pause");
return 0;
}
double getNew(double price,double percent,double amt)
{double p,a;
a=price-amt;
p=price-price*(percent/100.);
if(a>p)
    return a;
else
    return p;
}