SHARE
TWEET

Untitled

a guest Jun 19th, 2017 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //JosephEmersonHomework5Introductory11.cpp - Program calculates and displays
  2. //the total amount the customer owes.
  3. //Created/revised by Joseph Emerson on <October 4th, 2010
  4.  
  5. #include <iostream>
  6. #include <iomanip>
  7. using namespace std;
  8.  
  9. // declare functions
  10. void description();
  11. int getPounds();
  12. double getPrice();
  13. double getShipping();
  14. char getAnswer();
  15. double getTotal();
  16.  
  17. int main()
  18. {
  19.     //declare variables
  20.     double Shipping     = 15;
  21.     int Pounds          = 0;
  22.     double Price        = 0.0;
  23.     char answer         = ' ';
  24.     double totalPrice   = 0.0;
  25.     description();
  26.    
  27.     //enter input items
  28.     Shipping= getShipping();
  29.     Pounds= getPounds();
  30.     Price= getPrice();
  31.     totalPrice= getTotal();
  32.     system("pause");
  33.     return 0;
  34. }   //end of main function
  35.  
  36.     void description()
  37. {
  38.     cout << "This program displays the total amount the customer owes \n";
  39. }
  40.  
  41.     int getPounds()
  42. {
  43.     int Pounds ;
  44.     cout << "Total Pounds: ";
  45.     cin >> Pounds;
  46.     return Pounds;
  47. }
  48.  
  49.     double getPrice()
  50. {
  51.     double Price ;
  52.     cout << "Total Price Per Pound(s): ";
  53.     cin >> Price;
  54.     return Price;
  55. }
  56.  
  57.  
  58. double getShipping()
  59. {
  60.     double Shipping= 0 ;
  61.     cout << "Do you want shipping? Y or N? : .";
  62.     char answer= ' ';
  63.     answer=getAnswer();
  64.     if (answer == 'Y')
  65.     Shipping = 15;
  66.     return Shipping;
  67. }
  68.  
  69. char getAnswer()
  70. {
  71.     char answer= ' ';
  72.     cin >> answer;
  73.     return answer= ' ';
  74. }
  75.  
  76. double getTotal()
  77. {
  78.     double totalPrice, Price, Pounds, Shipping;
  79.     totalPrice= Price * Pounds + Shipping;
  80.     cout << "Total Price: " totalPrice ;
  81. }
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top