Advertisement
Garey

zad_1_osw - 50% done

Oct 10th, 2017
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.30 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //        NAME: main.cpp
  3. // DESCRIPTION: A program that helps a printer in making quotes for their
  4. //              products.
  5. //      AUTHOR: Stf Kolew
  6. // AUTHOR/DATE: 2017-10-10
  7. ////////////////////////////////////////////////////////////////////////////////
  8. #include <iostream>
  9. #include <iomanip>
  10.  
  11. using namespace std;
  12.  
  13. double const BLACK_WHITE_PRINTING = 0.01;
  14. double const COLOURFUL_PRINTING = 0.04;
  15. double const VAT = 17.5;
  16.  
  17. int const COLOURFUL_PLATE = 28;
  18. int const BINDING = 2;
  19. int const BLACK_WHITE_PLATE = 7;
  20.  
  21. ////////////////////////////////////////////////////////////////////////////////
  22. //        NAME: calculatePriceOfTheJob
  23. // DESCRIPTION: Calculates the price of a job given the number of pages, price
  24. //              per sheet, price per plate, and number of copies.
  25. //   ARGUMENTS: pages, copies, price_per_sheet(opt.), price_per_plate(opt.)
  26. // USES GLOBAL: BINDING
  27. // MODIFIES GL: none
  28. //     RETURNS: double
  29. //      AUTHOR: Stf Kolew
  30. // AUTHOR/DATE: JP 2017-10-10
  31. ////////////////////////////////////////////////////////////////////////////////
  32. double calculatePriceOfTheJob(int pages, int copies, double price_per_sheet = 0, int price_per_plate = 0) {
  33.   double total_price = (pages * price_per_plate) + (((pages / 2) * copies) * price_per_sheet) + (copies * BINDING);
  34.  
  35.   return total_price + (total_price * (VAT / 100));
  36. }
  37.  
  38. ////////////////////////////////////////////////////////////////////////////////
  39. //        NAME: calculatePriceOfTheJob2
  40. // DESCRIPTION: Calculates the price of a job given the number of pages and
  41. //              the number of copies for black and white printing using
  42. //              calculatePriceOfTheJob1 function
  43. //   ARGUMENTS: pages, copies
  44. // USES GLOBAL: BLACK_WHITE_PLATE, BLACK_WHITE_PRINTING, BINDING
  45. // MODIFIES GL: none
  46. //     RETURNS: double
  47. //      AUTHOR: Stf Kolew
  48. // AUTHOR/DATE: JP 2017-10-10
  49. ////////////////////////////////////////////////////////////////////////////////
  50. double calculatePriceOfBlackWhitePrinting(int pages, int copies) {
  51.   return calculatePriceOfTheJob(pages, copies, BLACK_WHITE_PRINTING, BLACK_WHITE_PLATE);
  52. }
  53.  
  54. ////////////////////////////////////////////////////////////////////////////////
  55. //        NAME: calculatePriceOfTheJob3
  56. // DESCRIPTION: Calculates the price of a job given the number of pages and
  57. //              the number of copies for black and colour printing using
  58. //              calculatePriceOfTheJob1 function
  59. //   ARGUMENTS: pages, copies
  60. // USES GLOBAL: COLOURFUL_PLATE, COLOURFUL_PRINTING, BINDING
  61. // MODIFIES GL: none
  62. //     RETURNS: double
  63. //      AUTHOR: Stf Kolew
  64. // AUTHOR/DATE: JP 2017-10-10
  65. ////////////////////////////////////////////////////////////////////////////////
  66. double calculatePriceOfColourfulPrinting(int pages, int copies) {
  67.   return calculatePriceOfTheJob(pages, copies, COLOURFUL_PRINTING, COLOURFUL_PLATE);
  68. }
  69.  
  70.  
  71. int main() {
  72.  
  73.   cout << "1000 colour books with 32 pages: " << fixed << setprecision(2) << calculatePriceOfColourfulPrinting(32, 1000) << endl;
  74.   cout << "1000 black/white books with 40 pages: " << calculatePriceOfBlackWhitePrinting(40, 2000) << endl;
  75.   cout << "400 black/white books with 160 pages: " << calculatePriceOfBlackWhitePrinting(160, 400) << endl;
  76.  
  77.   return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement