//Amari Mosley CSC5 Chapter 6, P. 369, #1
//
/*****************************************************************
 *
 * Calculate Markup
 * _______________________________________________________________
 * This program computes the retail price of an item based on its
 * wholesale cost and markup percentage.
 *
 * Computation is based on the formula:
 *   retail = wholesale + (wholesale * (markup / 100))
 * _______________________________________________________________
 * INPUT
 *   wholesale : the item's wholesale cost (must not be negative)
 *   markup    : the markup percentage (must not be negative)
 *
 * OUTPUT
 *   retail    : the item's retail price
 *
 *****************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;

// Function prototype
double calculateRetail(double wholesale, double markup);

int main()
{
    double wholesale;   // wholesale cost of the item
    double markup;      // markup percentage
    double retail;      // retail price of the item

    // Get wholesale cost with input validation
    cout << "Enter the item's wholesale cost: $";
    cin >> wholesale;
    while (wholesale < 0)
    {
        cout << "Wholesale cost cannot be negative. Please re-enter: $";
        cin >> wholesale;
    }

    // Get markup percentage with input validation
    cout << "Enter the markup percentage: ";
    cin >> markup;
    while (markup < 0)
    {
        cout << "Markup percentage cannot be negative. Please re-enter: ";
        cin >> markup;
    }

    // Calculate and display the retail price
    retail = calculateRetail(wholesale, markup);

    cout << fixed << setprecision(2);
    cout << "The item's retail price is $" << retail << endl;

    return 0;
}


 // calculateRetail
 //   Receives the wholesale cost and markup percentage and
 //   returns the retail price of the item.

double calculateRetail(double wholesale, double markup)
{
    return wholesale + (wholesale * (markup / 100));
}