54.2k views
0 votes
A customer in a store is purchasing five items. The prices of the five items are Price of item 1 = $15.95 Price of item 2 = $24.95 Price of item 3 = $6.95 Price of item 4 = $12.95 Price of item 5 = $3.95 Write a program that holds the prices of the five items in five variables. Display each item’s price, the subtotal of the sale, the amount of sales tax, and the total. Assume the sales tax is 7%

1 Answer

4 votes

Answer:

Follows are the code to this question:

#include<iostream>//defining a header file

using namespace std;

int main ()//defining a main method

{

float SubTotal,SalesTax,Total;//defining float variable for calculate the value

float item_1 = 15.95, item_2 = 24.95,item_3 = 6.95, item_4 = 12.95,item_5 = 3.95;//defining float variable and assign value

SubTotal = item_1+item_2+item_3+item_4+item_5;//use SubTotal to calculate the sum

SalesTax = SubTotal * 0.07;//use SalesTax to calculate 7% of SubTotal

Total = SubTotal + SalesTax ;//use Total to addd SubTotal and SalesTax

cout << "Price of item 1 : $"<< item_1 << endl;//print item_1 Price

cout << "Price of item 2 : $"<< item_2 <<endl;//print item_2 Price

cout << "Price of item 3 : $"<< item_3 <<endl;//print item_3 Price

cout << "Price of item 4 : $"<< item_4 <<endl;//print item_4 Price

cout << "Price of item 5 : $"<< item_5 <<endl;//print item_5 Price

cout <<"The SubTotal value is: $"<< SubTotal << endl;//print SubTotal value

cout <<"The SalesTax value is: $"<< SalesTax << endl;//print SalesTax value

cout << "The Total value is: $" << Total << endl;//print Total value

return 0;

}

output:

please find attached file.

Step-by-step explanation:

In the above-given code, three float variable that are "SubTotal, SalesTax, and Total" is define for calculating and store its value, and in the next line, another five float variable " item_1, item_2, item_3, item_4, and item_5" is declared that stores a float value which is defined in the question.

  • In the next line, the "SubTotal" variable is used to add the value of all items, and in the next line, the SalesTax is used to calculate the 7% of SubTotal and store its value.
  • At the last, the "Total" variable is defined that adds the "SubTotal and SalesTax" value and uses the print method to print all variable values.
A customer in a store is purchasing five items. The prices of the five items are Price-example-1
User Ouroboros
by
5.5k points