home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / TCPP30-3.ZIP / EXAMPLES.ZIP / SALESTAG.C < prev    next >
C/C++ Source or Header  |  1992-02-18  |  703b  |  33 lines

  1. // Borland C++ - (C) Copyright 1991 by Borland International
  2.  
  3. /* SALESTAG.C--Example from Getting Started.
  4.    SALESTAG.C calculates a sales slip. */
  5.  
  6. #include <stdio.h>
  7. #define RATE 0.065                         /* Sales Tax Rate */
  8.  
  9. float tax (float amount);
  10. float purchase, tax_amt, total;
  11.  
  12. int main()
  13. {
  14.    char inbuf [130];
  15.    printf("Amount of purchase: ");
  16.    gets(inbuf);
  17.    sscanf(inbuf, "%f", &purchase);
  18.  
  19.    tax_amt = tax(purchase);
  20.    total = purchase + tax_amt;
  21.  
  22.    printf("\nPurchase is:  %f", purchase);
  23.    printf("\n        Tax:  %f", tax_amt);
  24.    printf("\n      Total:  %f", total);
  25.  
  26.    return 0;
  27. }
  28.  
  29. float tax (float amount)
  30. {
  31.    return(amount * RATE);
  32. }
  33.