Respuesta :
Answer:
#include <iostream>
using namespace std;
int main()
{
float item[5], subTotal = 0.0, total, salesTax;
for (int k = 0; k<5; k++){
cout << "Enter the price of item "<<(k + 1)<<" - ";
cin>>item[k];
subTotal += item[k];
}
salesTax = subTotal * 7.25 / 100;
total = subTotal + salesTax;
cout<<"Sub Total = "<<subTotal<<endl;
cout<<"Sales Tax = "<<salesTax<<endl;
cout<<"Total = "<<total<<endl;
return 0;
}
Explanation:
I declared an array that will contain 5 values. This array stores the price of the five items that will be entered. A variable named subTotal is used to sum the price of the items entered. The variable total is used to store the total of the sales tax and the items subtotal. The program is written in C++
Answer:
Here is the python program:
item_price1 = float(input("Enter price of 1st item:" ))
item_price2 = float(input("Enter price of 2nd item: "))
item_price3 = float(input("Enter price of 3rd item: "))
item_price4 = float(input("Enter price of 4th item: "))
item_price5 = float(input("Enter price of 5th item: "))
sub_total_of_sale = (item_price1 + item_price2 + item_price3 + item_price4 + item_price5)
amount_of_sales_tax = sub_total_of_sale * 0.0725
total = sub_total_of_sale + amount_of_sales_tax
print("Sub Total of the Sale is: ",sub_total_of_sale)
print("The amount of sales tax is: ",amount_of_sales_tax)
print("Total is: ",total)
Explanation:
This program first prompts the user to enter price of 5 items and input() function is used here to let the user enter the price.
Next the sub_total_of_sale variable stores the sum of all these 5 items
amount_of_sales_tax stores the sum of sale tax which is 7.25% and sub total of 5 items. here 0.0725 means 7.25/100
total holds the sum of sub total of price of 5 items and sales tax.
Lastly it displays sub total of sale, amount of sales tax and total using print statement.