1 / 10

Example Program : Invoice Processing

Example Program : Invoice Processing. Details of an invoice are available as follows: The number of items on the invoice - n For each item an item code (6 digits), a quantity and a unit cost (pounds,pence) Thus a typical set of input values for an invoice might be: 3

cortess
Télécharger la présentation

Example Program : Invoice Processing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Example Program: Invoice Processing • Details of an invoice are available as follows: The number of items on the invoice - n For each item an item code (6 digits), a quantity and a unit cost (pounds,pence) Thus a typical set of input values for an invoice might be: 3 161432 5 6 50 543289 10 2 25 876234 2 10 75

  2. Example Program: Invoice Processing • indicating that there are three items on the invoice • the first item having an item code of 161432, an order quantity of 5 and a unit price of six pounds fifty pence. • Assume that the days date will also be entered. • Write a C++ program to enter details of such an invoice and to output an invoice which indicates the total cost of each item and the total cost of the invoice together with full details. • The above details might produce an invoice as follows:

  3. Example Program: Invoice Processing Invoice date: 10/6/96 Item quantity unit price total price 161432 5 6.50 32.50 543289 10 2.25 22.50 876234 2 10.75 21.50 Total 76.50

  4. Example Program: Invoice Processing • A first attempt at an algorithm might be: initialise. enter date. enter number of items into n. output headings. for n items do { enter a record. calculate total cost of item. accumulate total invoice cost. write line of invoice. } output total cost.

  5. Example Program: Invoice Processing • Assume that there are four programmers available to implement this program. • There are four major operations inside the for loop hence each programmer could be given one operation to implement. • The best way to do this is to use a function for each operation. • Each programmer can then be given a precise definition of a function.

  6. Example Program: Invoice Processing • For example consider the operation enter a record. • This function must read in the integer quantities item number, quantity and unit price in pounds and pence. • Hence it has no input parameters and four output parameters. • A definition of the function could then be written as follows:

  7. Example Program: Invoice Processing Function name: dataentry Operation: Enter a record Description: Enters four integers from the current input line and returns their values. Parameters: Output parameter int itemno Output parameter int quantity Output parameter int unitpounds Output parameter int unitpence

  8. Example Program: Invoice Processing Function name : calccost Operation : Calculates the cost for a single item. Description : Given the unit price of an item in pounds and pence and the quantity of the item calculates the total cost in pounds and pence. Parameters : Input parameter int quantity input parameter int unitpounds input parameter int unitpence output parameter int totalpound output parameter int totalpence

  9. Example Program: Invoice Processing Function name : acctotal Operation : Accumulates the total cost of invoice Description : Given current total invoice cost and the total cost of an invoice item calculates the new total invoice cost. Parameters : input parameter int totalpound input parameter int totalpence input & output parameter int invpound input & output parameter int invpence

  10. Example Program: Invoice Processing Function name : writeline Operation : Writes a line of the invoice. Description : Given the item reference number, the quantity, the unit price and total price of an item outputs a line of the invoice. Parameters : input parameter int itemno input parameter int quantity input parameter int unitpounds input parameter int unitpence input parameter int totalpound input parameter int totalpence

More Related