fork download
  1. /*******************************************************************
  2. Author: Caleb Elkins
  3. Date: February 26, 2017
  4. Course: CMIS 102
  5. Description: Get the base price of item and then use a function to
  6. add sales tax to that item.
  7. *******************************************************************/
  8. #include <stdio.h>
  9. int main()
  10. {
  11. float getTax(int price); //Prototype
  12.  
  13. int price;
  14. float total;
  15.  
  16. printf("Enter in the whole dollar amount price of an item: \n");
  17. scanf("%d", &price);
  18.  
  19. //Add sales tax
  20. total = getTax(price);
  21. printf("Price after tax: $%f \n", total);
  22. }
  23.  
  24.  
  25. //getTax function. Adds salestax to item's price and returns the total value
  26. float getTax(int price)
  27. {
  28. float salesTotal = price;
  29. float salesTax = 0.08;
  30.  
  31. salesTotal += (price * salesTax);
  32.  
  33. return salesTotal;
  34. }
Success #stdin #stdout 0s 9432KB
stdin
20534
stdout
Enter in the whole dollar amount price of an item: 
Price after tax: $22176.720703