fork download
  1. //Andrew Alspaugh CS1A Chapter 6. p. 369. #1
  2. //
  3. /************************************************************************
  4.  * Calculate Retail Price
  5.  *_______________________________________________________________________
  6.  * This program calculates takes the price of a wholesale item and
  7.  * calculates retail price of any markup rate
  8.  * _____________________________________________________________________
  9.  * INPUT
  10.  * whole Wholesale Price
  11.  * markup Markup Rate
  12.  * OUTPUT
  13.  * retail Retail Price
  14.  * **********************************************************************/
  15.  
  16. #include <iostream>
  17. using namespace std;
  18.  
  19. int main()
  20. {
  21. // Function Prototype Calculate
  22. float CalculateRetail(float whole, float markup);
  23.  
  24. //Data Dictionary
  25. float whole; //INPUT WHOLESALE PRICE
  26. float markup; //INPUT MARKUP RATE
  27.  
  28. float retail; //OUTPUT RETAIL PRICE
  29.  
  30. // INPUT
  31.  
  32. //Input Wholesale Price
  33. cout << "Enter Wholesale Price: " << endl;
  34. cin >> whole;
  35.  
  36. //Wholesale Validation
  37.  
  38. while(whole <= 0)
  39. {
  40. cout << "Wholesale price must be greater than 0" << endl;
  41. cin >> whole;
  42. }
  43. cout << "Wholesale price is: " << whole << endl;
  44.  
  45. //Input Markup Rate
  46. cout << "Enter Markup Rate: " << endl;
  47. cin >> markup;
  48.  
  49. //Markup Rate Validation
  50.  
  51. while (markup <= 0)
  52. {
  53. cout << "Markup rate must be greater than 0" << endl;
  54. cin >> markup;
  55. }
  56. cout << "Markup Rate is: " << markup << endl;
  57.  
  58. //PROCESS
  59.  
  60. retail = CalculateRetail(whole, markup);
  61.  
  62. //OUTPUT
  63.  
  64. cout << "Retail Price is: " << retail << endl;
  65.  
  66. return 0;
  67. }
  68. /**************************************************************************
  69.  * CalculateRetail() Definition
  70.  * multiplies whole by markup + 100 and divides the whole by 100 to calculate
  71.  * retail price
  72.  **************************************************************************/
  73.  
  74. float CalculateRetail(float whole, float markup)
  75. {
  76. return (whole * (markup + 100))/100;
  77. }
Success #stdin #stdout 0.01s 5304KB
stdin
5.00
100
stdout
Enter Wholesale Price: 
Wholesale price is: 5
Enter Markup Rate: 
Markup Rate is: 100
Retail Price is: 10