180-A2 - CSC180 Introduction to Computer Programming...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSC180 Introduction to Computer Programming Assignment 2 Due: 11:59 PM, October 27, 2008 1 Problem description Improve the receipt machine in the assignment 1. The program reads transac- tion time and purchases from standard input. Assume that standard input is al- ways valid. Hint: these library functions might be useful: strcpy (or strncpy ), strcmp (or strncmp ), and sscanf . This assignment is worth 4% toward your final grade. The receipt must have exactly the same format as shown below: Welcome to U of T Bookstore Koffler Student Services Bldg. 214 College St. Toronto, ON M5T 3A1 Phone: 416.640.7900 GST # R132094343 Sale Cashier: 263 10/10/08 12:00 11 2b $21.78 2 09 $21.64 12 DD $12.12 Subtotal: $55.54 Tax: GST: $2.17 PST: $1.73------ Total: $59.44 DEBIT CARD $60.00 12345678******** Change due: $0.56 Receipt required for all refunds 1 The above receipt was generated using the following function calls and the standard input under the second point in Section 2: init(263); purchase(); cancel(A1, 3); print(60.0, debit, 1234567887654321); We provide receipt.h ; its contents are listed below: /* receipt.h */ #define NUM 99 /* max number of distinct items */ #define SIZE 15 /* size of time string */ #define GST 0.05 /* GST tax rate */ #define PST 0.08 /* PST tax rate */ #define BANNER \tWelcome to U of T Bookstore\n\tKoffler Student Services Bldg.\n \ \t214 College St.\n\tToronto, ON M5T 3A1\n\tPhone: 416.640.7900\n \ \tGST # R132094343\n\n\t\tSale\n /* from getline.c */ int getline(char s, int lim); /* from receipt.c */ void init(int id); void purchase(void); void cancel(char *s, int q); void tax(char t, int q, double p, int n, double *gst, double *pst); double subtotal(int q, double p, int n); double total(double t, double gst, double pst); double change_due(double a); void print(double a, char *opt, char *cno); We also provide getline.c ; its contents are listed below: /* getline.c */ #include <stdio.h> /* get line into s, return length */ int getline(char s, int lim) { int c, i; i = 0; while (--lim > 0 && (c=getchar()) != EOF && c != \n) s[i++] = c; if (c == \n) s[i++] = c; s[i] = \0; return i; } 2 You must use receipt.h and getline.c in your program....
View Full Document

Page1 / 7

180-A2 - CSC180 Introduction to Computer Programming...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online