Chapter 2 – Q #3: Sales Tax – Tony Gaddis – Starting Out With C++

Chapter 2 – Q #3: Sales Tax – Tony Gaddis – Starting Out With C++

Chapter 2 – Q #3: Sales Tax



PROBLEM: 

Write a program that will compute the total sales tax on a $52 purchase. Assume the state sales tax is 4 percent and the county sales tax is 2 percent.


Solution:- 

#include <iostream>

using namespace std;

int main()

{

      const double purchase = 52;

      double state_tax = 4 / 100.0;

      double country_tax = 2 / 100.0;

      double total_tax = 0.0;

 

      total_tax = (state_tax * 52) + (country_tax * 52);

      cout << "Total Tax On This Purchase is  $" << total_tax;

      return 0;

}

This is the Solution of this problem.


Explanation Solution

  • First, we declare constant and initialize price of purchase.
  • Second, we calculate sales tax and  country tax.
  • Third, Calculation of Total tax by multiply taxes with purchase price.
  • Fourth, Display Output on the screen using cout. 



Also, I share the CPP file of this solution.

Post a Comment

0 Comments