In: Computer Science
- Delcare variable data type as decimal (5 variables needed) count, price, subtotal, tax, total
- Write a do while loop, if the price is not -1, loop continues show count number enter price get subtotal increase count
- Calculate tax, total
- Display total count, subtotal, tax, total
Note:
Could you please check the output.Any modifications needed let me know.Thank you.
_________________
#include <iostream>
using namespace std;
int main()
{
//Declaring variables
double count=0.0,price,subtotal=0.0,tax,total;
//Getting the price entered by the user
cout<<"Enter price : $";
cin>>price;
/* if the first price entered by the user
* is equal to -1 .then program
exit
*/
if(price==-1)
{
exit(0);
cout<<":: Program Exit
::"<<endl;
}
do
{
//Displaying the count value
cout<<"Count
:"<<++count<<endl;
//calculating the subtotal
subtotal+=price;
//getting the price
cout<<"Enter price : $";
cin>>price;
}while(price!=-1);
//Calculating the tax
tax=subtotal*0.05;
//calculating the total
total=subtotal+tax;
//displaying the output
cout<<"\nTotal Count
="<<count<<endl;
cout<<"Subtotal =
$"<<subtotal<<endl;
cout<<"Tax = $"<<tax<<endl;
cout<<"Total =
$"<<total<<endl;
return 0;
}
______________________
Output:

___________Thank You