Question: After that, answer the following question: Are all three parameters of the function processDisc(...) needed in this new form of the program? If yes, justify

After that, answer the following question: Are all three parameters of the function processDisc(...) needed in this new form of the program? If yes, justify why (in words). If no, eliminate the one(s) that is/are not necessary and make all changes such that the program compiles correctly.

#include

#include

using namespace std;

/*

Input:name, unit price, and discount

percentage for a number of products

Output: the discounted price or message

*/

float processDisc(string,float,int);//now the fc returns a float(discount)

int main()

{

string nameP;

float unitPr,discPr;

int perDisc;

char cont;

cont = 'Y';

while (cont == 'Y')

{

cout << "Name of product: ";

cin >> nameP;

cout << "Input unit price for " << nameP << ": ";

cin >> unitPr;

cout << "Input the discount percentage for " << nameP << ": ";

cin >> perDisc;

discPr= processDisc(nameP, unitPr, perDisc); //call fc.

if(perDisc>0)

cout << nameP << " sold at " << discPr << endl;

else

cout << nameP << " sold at regular price" << endl;

cout << " Continue? (Y/N): ";

cin >> cont;

}

return 0;

}

float processDisc(string nP, float uP, int pD)

{

float discPr;

if (pD > 0 )

discPr = uP - uP * pD /100;

else

discPr= uP;

return discPr;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!