Skip to content

Commit

Permalink
Add sales tax example
Browse files Browse the repository at this point in the history
  • Loading branch information
zachwill committed Sep 18, 2011
1 parent 41a3aeb commit a785697
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions 07_04_sales_tax.c
@@ -0,0 +1,38 @@
/*
* =====================================================================================
*
* Filename: 07_04_sales_tax.c
*
* Description: Exercise 7.4
* Write a program to add an 8% sales tax to a given amount
* and round the result to the nearest penny.
*
* Version: 1.0
* Created: 09/18/2011
* Revision: none
* Compiler: gcc
*
* Author: Zach Williams, hey AT zachwill DOT com
*
* =====================================================================================
*/

#include <stdio.h>
#include <stdlib.h>


float add_sales_tax(float original) {
float tax = 1.08, total;
total = original * tax;
return total;
}


int main(int argc, const char *argv[]) {
float input, total_amount;
input = atof(argv[1]);
total_amount = add_sales_tax(input);
printf("Price: %.2f\n", input);
printf("Total: %.2f\n", total_amount);
return 0;
}

0 comments on commit a785697

Please sign in to comment.