fork download
  1. //Xinnuo Wang CS1A chapter 2, P.81 # 3
  2. //
  3. /*******************************************************************************
  4.  *
  5.  * COMPUTE SALES TAX
  6.  *______________________________________________________________________________
  7.  * This program computes the total sales tax on a $52 purchase. Assume the
  8.  * state sales tax is 4 percent and the county sales tax is 2 percent.
  9.  *
  10.  * Computation is based on the formula:
  11.  * sales tax = price x percentage
  12.  * _____________________________________________________________________________
  13.  * INPUT
  14.  * price : The price of a staff
  15.  * percentage : The tax percentage of the staff
  16.  *
  17.  * OUTPUT
  18.  * sales tax : the tax of the staff
  19.  *
  20.  ******************************************************************************/
  21. #include <iostream>
  22. using namespace std;
  23.  
  24. int main()
  25. {
  26. int price; //INPUT - The price of a staff
  27. float percentage; //INPUT - The tax percentage of the staff
  28. float salesTax; //OUTPUT - the tax of the staff
  29. //
  30. // Initialize Program Variables
  31. price = 52;
  32. percentage = 0.02;
  33. //
  34. // compute Sales Tax
  35. salesTax = price * percentage;
  36. //
  37. // Output Result
  38. cout << "The sales tax is : $" << salesTax << "dollars" << endl;
  39. return 0;
  40. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
The sales tax is : $1.04dollars