Advertisement
Garey

ex1_tutorial

Oct 10th, 2017
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.43 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //        NAME: main.cpp
  3. // DESCRIPTION: A program that helps a printer in making quotes for
  4. //              their products.
  5. // AUTHOR/DATE: JP 2017-10-10
  6. ////////////////////////////////////////////////////////////////////////////////
  7. #include <iostream>
  8. #include <iomanip>
  9.  
  10. using namespace std;
  11.  
  12. ////////////////////////////////////////////////////////////////////////////////
  13. //        NAME: calculate_the_job
  14. // DESCRIPTION: Calculates the price of a job given the number of pages,
  15. //              price per sheet, price per plate, and number of copies.
  16. //   ARGUMENTS: number_of_pages, number_of_copies, price_per_sheet,
  17. //              price_per_plate
  18. // USES GLOBAL: none
  19. // MODIFIES GL: none
  20. //     RETURNS: double number
  21. // AUTHOR/DATE: JP 2017-10-10
  22. ////////////////////////////////////////////////////////////////////////////////
  23. double calculate_the_job(int number_of_pages, int number_of_copies, double price_per_sheet, double price_per_plate) {
  24.   return (((number_of_pages * price_per_plate) + (((number_of_pages / 2) * number_of_copies) * price_per_sheet) + (number_of_copies * 2.00)) + (((number_of_pages * price_per_plate) + (((number_of_pages / 2) * number_of_copies) * price_per_sheet) + (number_of_copies * 2.00)) * (17.5 / 100)));
  25. }
  26.  
  27. ////////////////////////////////////////////////////////////////////////////////
  28. //        NAME: calculate_bw_printing
  29. // DESCRIPTION: Calculates the price of a job given the number of pages and
  30. //              the number of copies for black and white printing.
  31. //   ARGUMENTS: number_of_pages, number_of_copies
  32. // USES GLOBAL: none
  33. // MODIFIES GL: none
  34. //     RETURNS: double number
  35. // AUTHOR/DATE: JP 2017-10-10
  36. ////////////////////////////////////////////////////////////////////////////////
  37. double calculate_bw_printing(int number_of_pages, int number_of_copies) {
  38.   return calculate_the_job(number_of_pages, number_of_copies, 0.01, 7);
  39. }
  40.  
  41. ////////////////////////////////////////////////////////////////////////////////
  42. //        NAME: calculate_color_printing
  43. // DESCRIPTION: Calculates the price of a job given the number of pages and
  44. //              the number of copies for color printing.
  45. //   ARGUMENTS: number_of_pages, number_of_copies
  46. // USES GLOBAL: none
  47. // MODIFIES GL: none
  48. //     RETURNS: double number
  49. // AUTHOR/DATE: JP 2017-10-10
  50. ////////////////////////////////////////////////////////////////////////////////
  51. double calculate_color_printing(int number_of_pages, int number_of_copies) {
  52.   return calculate_the_job(number_of_pages, number_of_copies, 0.04, 28);
  53. }
  54.  
  55. ////////////////////////////////////////////////////////////////////////////////
  56. //        NAME: main
  57. // DESCRIPTION: The main fragment of the program. Outputs information
  58. //              about the functions that are described above.It has
  59. //              been used manipulators to output two numbers after
  60. //              the decimal part of the number.
  61. //              Manipulators Used: setprecision and fixed
  62. //   ARGUMENTS: none
  63. // USES GLOBAL: none
  64. // MODIFIES GL: none
  65. //     RETURNS: int(1)
  66. // AUTHOR/DATE: JP 2017-10-10
  67. ////////////////////////////////////////////////////////////////////////////////
  68. int main() {
  69.  
  70.   cout << fixed << setprecision(2) << calculate_color_printing(32, 1000) << endl;
  71.   cout << calculate_bw_printing(40, 2000) << endl;
  72.   cout << calculate_bw_printing(160, 400) << endl;
  73.  
  74.   return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement