fork download
  1. // Jeremy Huang CS1A Chapter 2, Pp. 81, #3
  2.  
  3. /*****************************************************************************
  4.  * COMPUTE TOTAL SALES TAX
  5.  * ____________________________________________________________________________
  6.  * This program calculates the amount of sales tax made on a purchase. The user
  7.  * inputs the cost of the item, the state sales tax, and the county sales tax
  8.  * in which the program takes those sales taxes and applies it to the item to
  9.  * determine the tax amounts. The program then sums the state tax and county
  10.  * tax to determine the total sales tax on the purchase.
  11.  * ___________________________________________________________________________
  12.  * INPUT
  13.  * cost : cost of the item
  14.  * stateTax : the states sales tax
  15.  * countyTax : the countys sales tax
  16.  *
  17.  * OUTPUT
  18.  * totalTax : sum of the state tax and the county tax on the purchase
  19.  *
  20.  * **************************************************************************/
  21.  
  22. #include <iostream>
  23. using namespace std;
  24.  
  25. int main() {
  26. //Declaring variables
  27. int cost = 52;
  28. float stateTax = 0.04;
  29. float countyTax = 0.02;
  30.  
  31. //Computing total tax through sum of both taxes
  32. float totalTax = (cost*stateTax)+(cost*countyTax);
  33.  
  34. //Output
  35. cout<<"The total tax on the $"<<cost<<" purchase is $"<<totalTax<<".";
  36.  
  37. //End program
  38. return 0;
  39. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
The total tax on the $52 purchase is $3.12.