//Andres Guzman CSC5 Chapter 6, P. 369, #1
//
/*******************************************************************************
*
* CALCULATE RETAIL PRICE
* ______________________________________________________________________________
* This program will calculate the retail price of a wholesale item after markup
*
* Computation:
*
* retail = wholesale + (wholesale * markup / 100)
* ______________________________________________________________________________
* INPUT
*
* float wholesale = Original cost of an item
* float markup = percentage increase
*OUTPUT
* float retail = price of item after increase
*
*******************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
float wholesale; //Global Variable
float markup; //Global Variable
float retail; //Global Variable
void calculateretail(float wholesale, float markup); //prototype
int main ()
{
//
//Ask user for wholesale
cout << "Wholesale Cost: $";
cin >> wholesale;
//
//Creating while loop for input validation
while(wholesale < 0)
{
cout << "\nInvalid Input, please enter positive values. ";
cout << "\n\nWholesale Cost: $";
cin >> wholesale;
}
//
//Ask user for markup
cout << "\nMarkup Percentage: %";
cin >> markup;
//
//Creating while loop for input validation
while(markup < 0)
{
cout << "\nInvalid Input, please enter positive values. ";
cout << "\n\nWholesale Cost: $";
cin >> markup;
}
calculateretail(wholesale, markup); //function call
cout << fixed << setprecision(2) << "\nRetail Price: $" << retail << endl;
return 0;
}
/*******************************************************************************
* Adding definition to function calculateretail. Parameters hold wholesale and
* markup variables. Function will calculate the retail price.
******************************************************************************/
void calculateretail(float wholesale, float markup)
{
retail = wholesale + (wholesale * markup / 100);
}