SHARE
TWEET

Untitled

a guest Jun 19th, 2017 43 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.  
  16.  
  17. int main()
  18. {
  19.     //declare variables
  20.     double Shipping     = 15;
  21.     int Pounds          = 0;
  22.     double Price        = 0.0;
  23.     double totalPrice   = 0.0;
  24.     char answer         = ' ';
  25.     description();
  26.    
  27.     //enter input items
  28.     Shipping= getShipping();
  29.     Pounds= getPounds();
  30.     Price= getPrice();
  31.    
  32.     cout << " " << Price ;
  33.     cout << " " << Pounds;
  34.     cout << " " << Shipping;
  35.     totalPrice= Price * Pounds + Shipping;
  36.     cout << "Total Price: " << totalPrice << endl;
  37.    
  38.     system("pause");
  39.     return 0;
  40. }   //end of main function
  41.  
  42.     void description()
  43. {
  44.     cout << "This program displays the total amount the customer owes \n";
  45. }
  46.  
  47.     int getPounds()
  48. {
  49.     int Pounds ;
  50.     cout << "Total Pounds: ";
  51.     cin >> Pounds;
  52.     return Pounds;
  53. }
  54.  
  55.     double getPrice()
  56. {
  57.     double Price ;
  58.     cout << "Total Price Per Pound(s): ";
  59.     cin >> Price;
  60.     return Price;
  61. }
  62.  
  63.  
  64. double getShipping()
  65. {
  66.     double Shipping= 0 ;
  67.     cout << "Do you want shipping? Y or N? : ";
  68.     char answer= ' ';
  69.     answer=getAnswer();
  70.     if (answer == 'Y')
  71.     Shipping = 15;
  72.     return Shipping;
  73. }
  74.  
  75. char getAnswer()
  76. {
  77.     char answer= ' ';
  78.     cin >> answer;
  79.     return answer= ' ';
  80. }
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top