//Devin Scheu CS1A Chapter 6, P. 369, #1
//
/**************************************************************
*
* CALCULATE RETAIL PRICE WITH MARKUP
* ____________________________________________________________
* This program determines the retail price of an item based
* on its wholesale cost and markup percentage.
* ____________________________________________________________
* INPUT
* wholesaleCost : The wholesale cost of the item
* markupPercentage : The markup percentage for the item
*
* OUTPUT
* retailPrice : The calculated retail price of the item
*
**************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
// Function to calculate retail price
double calculateRetail(double wholesaleCost, double markupPercentage) {
double markupAmount = wholesaleCost * (markupPercentage / 100);
return wholesaleCost + markupAmount;
}
int main () {
//Variable Declarations
double wholesaleCost; //INPUT - The wholesale cost of the item
double markupPercentage; //INPUT - The markup percentage for the item
double retailPrice; //OUTPUT - The calculated retail price of the item
//Prompt for Input and Echo
cout << "Enter the item's wholesale cost: $";
cin >> wholesaleCost;
while (wholesaleCost < 0) {
cout << "\nError: Please enter a non-negative wholesale cost: $";
cin >> wholesaleCost;
}
cout << wholesaleCost << endl;
//Prompt for Input and Echo
cout << "Enter the markup percentage: ";
cin >> markupPercentage;
while (markupPercentage < 0) {
cout << "\nError: Please enter a non-negative markup percentage: ";
cin >> markupPercentage;
}
cout << markupPercentage << "%" << endl;
//Separator and Output Section
cout << "-------------------------------------------------------" << endl;
cout << "OUTPUT:" << endl;
//Calculate Retail Price
retailPrice = calculateRetail(wholesaleCost, markupPercentage);
//Output Result
cout << fixed << setprecision(2);
cout << left << setw(25) << "Wholesale Cost:" << right << setw(15) << "$" << wholesaleCost << endl;
cout << left << setw(25) << "Markup Percentage:" << right << setw(15) << markupPercentage << "%" << endl;
cout << left << setw(25) << "Retail Price:" << right << setw(15) << "$" << retailPrice << endl;
} //end of main()