home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c021 / 7.img / EXAMPLES.ZIP / SALESTAG.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-04  |  653 b   |  31 lines

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