A program that calculates the total of a retail sale. The program must ask user for retail price of item purchased and the sales tax rate. The program should then calculate and display on screen the sales tax amount for purchase and the total.
If someone can write out program for me I'm kinda stuck I'm a new c ++ student
#include <iostream>
#include <iomanip>
int main()
{
// ask user for retail price of item purchased
std::cout << "please enter the retail price of item purchased: " ;
// read the user input into a variable
double retail_price ;
std::cin >> retail_price ;
// ask user for sales tax rate
std::cout << "please enter the sales tax rate as a percentage: " ;
// read the user input into another variable
double percent_sales_tax ;
std::cin >> percent_sales_tax ;
// if the retail price and sales tax rate are positive values
if( retail_price > 0 && percent_sales_tax > 0 )
{
// compute sales tax amount
constdouble sales_tax_amount = retail_price * percent_sales_tax / 100.0 ;
// calculate total amount
constdouble gross_amount = retail_price + sales_tax_amount ;
// display on screen the sales tax amount for purchase and the total.
std::cout << std::fixed // fixed point format,
<< std::setprecision(2) // with two digits after the decimal point
<< "sales tax amount: " << sales_tax_amount << '\n'
<< " total amount: " << gross_amount << '\n' ;
}
else std::cout << "there was an error in the data that was entered.\n" ; // invalid input
}