Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //JosephEmersonHomework5Introductory11.cpp - Program calculates and displays
- //the total amount the customer owes.
- //Created/revised by Joseph Emerson on <October 4th, 2010
- #include <iostream>
- #include <iomanip>
- using namespace std;
- // declare functions
- void description();
- int getPounds();
- double getPrice();
- double getShipping();
- char getAnswer();
- int main()
- {
- //declare variables
- double Shipping = 15;
- int Pounds = 0;
- double Price = 0.0;
- double totalPrice = 0.0;
- char answer = ' ';
- description();
- //enter input items
- Shipping= getShipping();
- Pounds= getPounds();
- Price= getPrice();
- cout << " " << Price ;
- cout << " " << Pounds;
- cout << " " << Shipping;
- totalPrice= Price * Pounds + Shipping;
- cout << "Total Price: " << totalPrice << endl;
- system("pause");
- return 0;
- } //end of main function
- void description()
- {
- cout << "This program displays the total amount the customer owes \n";
- }
- int getPounds()
- {
- int Pounds ;
- cout << "Total Pounds: ";
- cin >> Pounds;
- return Pounds;
- }
- double getPrice()
- {
- double Price ;
- cout << "Total Price Per Pound(s): ";
- cin >> Price;
- return Price;
- }
- double getShipping()
- {
- double Shipping= 0 ;
- cout << "Do you want shipping? Y or N? : ";
- char answer= ' ';
- answer=getAnswer();
- if (answer == 'Y')
- Shipping = 15;
- return Shipping;
- }
- char getAnswer()
- {
- char answer= ' ';
- cin >> answer;
- return answer= ' ';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement