Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////////////
- // NAME: main.cpp
- // DESCRIPTION: A program that helps a printer in making quotes for
- // their products.
- // AUTHOR: Stf Kolew
- // AUTHOR/DATE: JP 2017-10-11
- // MODIFY/DATE: JP 2017-10-12
- ////////////////////////////////////////////////////////////////////////////////
- #include <iostream>
- #include <iomanip>
- using namespace std;
- ////////////////////////////////////////////////////////////////////////////////
- // NAME: round
- // DESCRIPTION: Rounds down or up, respectively to the number,
- // to the nearest multiple of the number.
- // ARGUMENTS: numer, multiple
- // USES GLOBAL: none
- // MODIFIES GL: none
- // RETURNS: int
- // AUTHOR: Stf Kolew
- // AUTHOR/DATE: JP 2017-10-11
- // MODIFY/DATE: JP 2017-10-12
- ////////////////////////////////////////////////////////////////////////////////
- #define roundNumber(number, multiple) ( number % multiple < 8 ? (number >= 0 ? (number / multiple) * multiple : ((number - multiple + 1) / multiple) * multiple) : (number >= 0 ? ((number + multiple - 1) / multiple) * multiple : (number / multiple) * multiple))
- ////////////////////////////////////////////////////////////////////////////////
- // NAME: calculate_the_job
- // DESCRIPTION: Calculates the price of a job given the number of pages,
- // price per sheet, price per plate, and number of copies.
- // ARGUMENTS: number_of_pages, number_of_copies, price_per_sheet,
- // price_per_plate
- // USES GLOBAL: none
- // MODIFIES GL: none
- // RETURNS: double number
- // AUTHOR: Stf Kolew
- // AUTHOR/DATE: JP 2017-10-12
- ////////////////////////////////////////////////////////////////////////////////
- double calculate_the_job(int number_of_pages, int number_of_copies, int print_car_pages, double price_per_sheet, double price_per_plate) {
- number_of_pages = roundNumber(number_of_pages, print_car_pages);
- 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)));
- }
- ////////////////////////////////////////////////////////////////////////////////
- // NAME: calculate_bw_printing
- // DESCRIPTION: Calculates the price of a job given the number of pages and
- // the number of copies for black and white printing.
- // ARGUMENTS: number_of_pages, number_of_copies
- // USES GLOBAL: none
- // MODIFIES GL: none
- // RETURNS: double number
- // AUTHOR: Stf Kolew
- // AUTHOR/DATE: JP 2017-10-12
- ////////////////////////////////////////////////////////////////////////////////
- double calculate_bw_printing(int number_of_pages, int number_of_copies, int print_car_pages) {
- return calculate_the_job(number_of_pages, number_of_copies, print_car_pages, 0.01, 7);
- }
- ////////////////////////////////////////////////////////////////////////////////
- // NAME: calculate_color_printing
- // DESCRIPTION: Calculates the price of a job given the number of pages and
- // the number of copies for color printing.
- // ARGUMENTS: number_of_pages, number_of_copies
- // USES GLOBAL: none
- // MODIFIES GL: none
- // RETURNS: double number
- // AUTHOR: Stf Kolew
- // AUTHOR/DATE: JP 2017-10-12
- ////////////////////////////////////////////////////////////////////////////////
- double calculate_color_printing(int number_of_pages, int number_of_copies,int print_car_pages) {
- return calculate_the_job(number_of_pages, number_of_copies, print_car_pages, 0.04, 28);
- }
- ////////////////////////////////////////////////////////////////////////////////
- // NAME: main
- // DESCRIPTION: The main fragment of the program. Outputs information
- // about the functions that are described above.It has
- // been used manipulators to output two numbers after
- // the decimal part of the number.
- // Manipulators Used: setprecision and fixed
- // ARGUMENTS: none
- // USES GLOBAL: none
- // MODIFIES GL: none
- // RETURNS: int(0)
- // AUTHOR: Stf Kolew
- // AUTHOR/DATE: JP 2017-10-12
- ////////////////////////////////////////////////////////////////////////////////
- int main() {
- // 1 Print Car
- cout << fixed << setprecision(2) << calculate_the_job(16, 1, 1, 0.01, 7) << endl;
- // 50 copies of books with 30 pages each, rounded down to 16 pages
- // due to 1 print car = 16 pages.
- cout << calculate_color_printing(30, 50, 16) << endl;
- // 35 copies of books with 34 pages each. Uses 2 print cars
- // Due to 34's lowest multiple of 16 is 32.
- cout << calculate_bw_printing(34, 35, 16) << endl;
- // 35 copies of books with 34 pages each where print car
- // pages equals 8.
- cout << calculate_bw_printing(34, 35, 8) << endl;
- // 100 copies of books with 34 pages each where print car
- // pages equals 6.
- cout << calculate_bw_printing(34, 100, 6) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement