fork(1) download
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4. int main(){
  5. int iItemNum=0;
  6. double dItemCost=0, dTax=0, dTotal=0, dGT=0;
  7.  
  8. cout <<"How many items do you have? ";
  9. cin >> iItemNum;
  10.  
  11. cout << "\nHow much does each item cost? ";
  12. cin >> dItemCost;
  13.  
  14. // 5% on any item below $500.00 / and 6% on any item above $500.00
  15.  
  16. if (dItemCost < 500){
  17. dTotal= iItemNum * dItemCost;
  18. dTax = dTotal * .05;
  19. }
  20. else{
  21. dTotal= iItemNum * dItemCost;
  22. dTax = dTotal * .06;
  23. }
  24.  
  25. dGT = dTotal + dTax;
  26. cout <<setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
  27. cout << "\nThe subtotal of the items is: " << dTotal << "\nThe tax on these items is: " << dTax << "\nSo the grand total of your order is: " <<dGT;
  28.  
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0s 2860KB
stdin
500
10.00
stdout
How many items do you have? 
How much does each item cost? 
The subtotal of the items is: 5000.00
The tax on these items is: 250.00
So the grand total of your order is: 5250.00