fork download
  1. //Cecilia Rangel CSC5 Chapter 6, P.374, #16
  2. //
  3. /**************************************************************
  4.  *
  5.  * TRANSIENT POLUTION
  6.  * ____________________________________________________________
  7.  * This program will ask for the user to input a positive
  8.  * number, and decimal point, and calculates the retail
  9.  *
  10.  *_____________________________________________________________
  11.  * INPUT
  12.  * user input : wholesesale cost and markup percentage
  13.  * OUTPUT
  14.  * price : retail price
  15.  *
  16.  *
  17.  **************************************************************/
  18. #include <iostream>
  19. #include <iomanip>
  20. using namespace std;
  21.  
  22. //Function prototype
  23. float calculateRetail(float, float);
  24.  
  25. int main() {
  26. //Variables to be used
  27.  
  28. float wholeSale;
  29. float markup;
  30. float retailPrice;
  31.  
  32. //Retrieving user input
  33.  
  34. cout << "What is the wholesale cost?" << endl;
  35. cin >> wholeSale;
  36. cout << "What is the markup percentage?" << endl;
  37. cin >> markup;
  38.  
  39. //If statement not allowing negative numbers
  40.  
  41. if (wholeSale < 0 || markup < 0){
  42. cout << "No negative numbers will be accepted.";
  43. }
  44. retailPrice = calculateRetail(wholeSale, markup);
  45. //Formatting and displaying output
  46.  
  47. cout << fixed << setprecision(2);
  48. cout << "The retail price is " << retailPrice;
  49.  
  50.  
  51. return 0;
  52. }
  53. //*********************************************************
  54. // Definition of function calculateRetail. *
  55. // This function displays the retail price of an item. *
  56. // ********************************************************
  57. float calculateRetail(float wholeS, float markup)
  58. {
  59. return ((wholeS * markup) + wholeS);
  60. }
Success #stdin #stdout 0s 5320KB
stdin
20
.70
stdout
What is the wholesale cost?
What is the markup percentage?
The retail price is 34.00