- 13 Ocak 2018
- 41
- 0
Yardım edebilecek var mı?
This exercise should familiarise you with functions and parameters. You will have to design and implement a program that helps a printer in making quotes for their products. There are many ways to write this program, but it is essential that you use [FONT="]functions[/FONT] and that you do [FONT="]not[/FONT] use any global variables (you will not even need local variables)
PART 1 (worth 50%): A printer has the following pricing system for books. For black and white printing, each sheet of paper costs a penny. In addition, they have to make a plate for each page of the original, costing 7 pounds. For colour printing, each sheet of paper costs 4 pennies, and the plates are 28 pounds. Binding costs 2 pound per copy of the book. These prices exclude 17.5% VAT (VAT has not yet risen on this bookbinder's planet). The printing is double sided.
As an example, printing 400 black and white books with 100 pages each costs:
100*7 pounds - [FONT="]£ 700.00 for the plates[/FONT]
[FONT="][FONT="](100/2)*400*1 pennies - [/FONT][/FONT][FONT="]£ 200.00 for the papers (2 papers per sheet)[/FONT]
400*2 pounds - [FONT="]£ 800.00 for the binding[/FONT]
[FONT="] Subtotal - [/FONT][FONT="][FONT="]£[/FONT] 1700.00[/FONT]
VAT - [FONT="]£ 297.50 17.5 over 1700.00 pounds[/FONT]
[FONT="] Grand Total - [/FONT][FONT="]£ 1997.50[/FONT]
[FONT="]1. [/FONT]Write a function that calculates the price of a job given the number of pages, price per sheet, price per plate, and number of copies.
[FONT="]2. [/FONT]Write a function that calculates the price of a job given the number of pages and the number of copies for black and white printing. This function should call the function that you wrote for part 1.
[FONT="]3. [/FONT]Write a function that calculates the price of a job given the number of pages and the number of copies for colour printing. This function should call the function that you wrote for part 1.
[FONT="]4. [/FONT]Write a main program that calculates the total price of printing 1000 colour books with 32 pages, 2000 black/white books with 40 pages and 400 black/white books with 160 pages. The main function should call the functions that you wrote for parts 2 and 3.
PART 2 (worth 50%):
[FONT="]1. [/FONT]Change the function that calculates the price of a job so that it assumes that books are printed with 16-fold signatures. (ie, the number of sheets is rounded up to the nearest multiple of 16).
Change the main function so that it prints in addition to the previous number:
The price of printing 50 colour books of 30 pages each with 16-fold signatures.
The price of printing 35 black and white books of 34 pages each with 16-fold signatures.
Please note: You don't need to change the parameters of your functions for this part. Each [FONT="]printed page[/FONT] (including partially printed pages) will need a plate, but blank pages won't. You may print out the first answer using a 16 fold signature as well for this part. Three numbers should therefore be printed for this extension.
You may wish to find out how to obtain remainders in C using the modulus operator [FONT="]%[/FONT], for example [FONT="]a % b[/FONT] in C will give the integer remainder when a is divided by b. You may also want to look at 'typecasting' - forcing conversion from one type into another type - because it is a common technique used for rounding in C. For example, typecasting a non-whole number as an integer will round it down to the nearest integer, e.g. [FONT="](int) 3.14159[/FONT] will evaluate to exactly 3.
[FONT="]2. [/FONT]Change the functions so that the number of pages in a signature is passed as a parameter. (ie, the number of sheets is rounded up to the nearest multiple of [FONT="]n[/FONT], where [FONT="]n[/FONT] is the size of the signature)
Change the main function so that it prints in addition to the previous three numbers:
The price of printing 35 black and white books of 34 pages each with 8 fold signatures.
The price of printing 100 black and white books of 34 pages each with 6 fold signatures.
Please note: For this extension you must print 5 numbers (the original [under a 16 fold signature], two for the first extension, two for this second extension).
[FONT="]
[/FONT]
[FONT="]
[/FONT]
This exercise should familiarise you with functions and parameters. You will have to design and implement a program that helps a printer in making quotes for their products. There are many ways to write this program, but it is essential that you use [FONT="]functions[/FONT] and that you do [FONT="]not[/FONT] use any global variables (you will not even need local variables)
PART 1 (worth 50%): A printer has the following pricing system for books. For black and white printing, each sheet of paper costs a penny. In addition, they have to make a plate for each page of the original, costing 7 pounds. For colour printing, each sheet of paper costs 4 pennies, and the plates are 28 pounds. Binding costs 2 pound per copy of the book. These prices exclude 17.5% VAT (VAT has not yet risen on this bookbinder's planet). The printing is double sided.
As an example, printing 400 black and white books with 100 pages each costs:
100*7 pounds - [FONT="]£ 700.00 for the plates[/FONT]
[FONT="][FONT="](100/2)*400*1 pennies - [/FONT][/FONT][FONT="]£ 200.00 for the papers (2 papers per sheet)[/FONT]
400*2 pounds - [FONT="]£ 800.00 for the binding[/FONT]
[FONT="] Subtotal - [/FONT][FONT="][FONT="]£[/FONT] 1700.00[/FONT]
VAT - [FONT="]£ 297.50 17.5 over 1700.00 pounds[/FONT]
[FONT="] Grand Total - [/FONT][FONT="]£ 1997.50[/FONT]
[FONT="]1. [/FONT]Write a function that calculates the price of a job given the number of pages, price per sheet, price per plate, and number of copies.
[FONT="]2. [/FONT]Write a function that calculates the price of a job given the number of pages and the number of copies for black and white printing. This function should call the function that you wrote for part 1.
[FONT="]3. [/FONT]Write a function that calculates the price of a job given the number of pages and the number of copies for colour printing. This function should call the function that you wrote for part 1.
[FONT="]4. [/FONT]Write a main program that calculates the total price of printing 1000 colour books with 32 pages, 2000 black/white books with 40 pages and 400 black/white books with 160 pages. The main function should call the functions that you wrote for parts 2 and 3.
PART 2 (worth 50%):
[FONT="]1. [/FONT]Change the function that calculates the price of a job so that it assumes that books are printed with 16-fold signatures. (ie, the number of sheets is rounded up to the nearest multiple of 16).
Change the main function so that it prints in addition to the previous number:
The price of printing 50 colour books of 30 pages each with 16-fold signatures.
The price of printing 35 black and white books of 34 pages each with 16-fold signatures.
Please note: You don't need to change the parameters of your functions for this part. Each [FONT="]printed page[/FONT] (including partially printed pages) will need a plate, but blank pages won't. You may print out the first answer using a 16 fold signature as well for this part. Three numbers should therefore be printed for this extension.
You may wish to find out how to obtain remainders in C using the modulus operator [FONT="]%[/FONT], for example [FONT="]a % b[/FONT] in C will give the integer remainder when a is divided by b. You may also want to look at 'typecasting' - forcing conversion from one type into another type - because it is a common technique used for rounding in C. For example, typecasting a non-whole number as an integer will round it down to the nearest integer, e.g. [FONT="](int) 3.14159[/FONT] will evaluate to exactly 3.
[FONT="]2. [/FONT]Change the functions so that the number of pages in a signature is passed as a parameter. (ie, the number of sheets is rounded up to the nearest multiple of [FONT="]n[/FONT], where [FONT="]n[/FONT] is the size of the signature)
Change the main function so that it prints in addition to the previous three numbers:
The price of printing 35 black and white books of 34 pages each with 8 fold signatures.
The price of printing 100 black and white books of 34 pages each with 6 fold signatures.
Please note: For this extension you must print 5 numbers (the original [under a 16 fold signature], two for the first extension, two for this second extension).
[FONT="]
[/FONT]
[FONT="]
[/FONT]
Moderatör tarafında düzenlendi: