C programming windows console applicationSolutioninclude inc
C++ programming windows console application
Solution
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
void calc(double price,double pct,double &result)
{
result = (price*(100+pct))/100;
}
int main()
{
double price = 0;
double pct=0;
double result=0;
while(true)
{
cout<<\"Enter the price of the product:\";
cin>>price;
if(price<0)
{
cout<<\"You should only enter non-negative values.\"<<endl;
}
else
{
break;
}
}
while(true)
{
cout<<\"Enter the markup percentage as a decimal:\";
cin>>pct;
if(pct<0)
{
cout<<\"You should only enter non-negative values.\"<<endl;
}
else
{
break;
}
}
calc(price,pct,result);
cout<<fixed<<showpoint;
cout<<setprecision(2);
cout<<\"Wholesale Cost: \"<<price<<endl;
cout<<\"Markup Percent: \"<<pct<<endl;
cout<<\"Retail Cost: \"<<result<<endl;
return 0;
}
