fork download
  1. //Matthew Santos CS1A Ch. 2, P.81, #3
  2. /**************************************************
  3.  *
  4.  * CALCULATE SALES TAX
  5.  * ________________________________________________
  6.  *
  7.  * This code computes and outputs the total
  8.  * sales tax on a $52 purchase.
  9.  * ________________________________________________
  10.  *
  11.  * INPUT
  12.  * price : price of purchase without tax ($52)
  13.  * statetax : tax taken from state (4%)
  14.  * countrytax : tax taken from country (2%)
  15.  *
  16.  * OUTPUT
  17.  * totaltax : total amount of tax on purchase
  18.  *
  19.  * ************************************************/
  20.  
  21. #include <iostream>
  22. using namespace std;
  23.  
  24. int main() {
  25.  
  26. //Determine price and tax
  27. float price = 52.0;
  28. float statetax = .04;
  29. float countrytax = .02;
  30. float totaltax;
  31.  
  32. //Calulates total tax
  33. totaltax = (price * statetax) + (price * countrytax);
  34.  
  35. //Outputs total tax
  36. cout << "Total tax: $" << totaltax;
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Total tax: $3.12