In: Computer Science
Project 7-6: Sales Tax Calculator
Create a program that uses a separate module to calculate sales tax and total after tax.
Create a c++ program using console.h and console.cpp files that uses a separate module to calculate sales tax and total after tax.
Console
Sales Tax Calculator
ENTER ITEMS (ENTER 0 TO END)
Cost of item: 35.99
Cost of item: 27.50
Cost of item: 19.59
Cost of item: 0
Total: 83.08
Sales tax: 4.98
Total after tax: 88.06
Again? (y/n): y
ENTER ITEMS (ENTER 0 TO END)
Cost of item: 152.50
Cost of item: 59.80
Cost of item: 0
Total: 212.30
Sales tax: 12.74
Total after tax: 225.04
Again? (y/n): n
Thanks, bye!
Specifications
been added. • Use the implementation file for this header file to store the sales tax rate and the definitions for these two functions. These functions should round the results to two decimal places. • The output should display all monetary values with 2 decimal places. • The output should right align the numbers in the second column. This makes it easier to check whether the calculations are correct.
header file sales.h
#include<iostream>
using namespace std;
float Sales_tax(float total)
{
return 0.06*total;
}
float total_new(float total)
{
float a=Sales_tax(total);
return total+a;
}
main file
#include <iostream>
#include <iomanip>
#include "sales.h"
using namespace std;
int main()
{
cout<<"Sales Tax Calculator"<<endl;
char flag='y';
float cost,total=0;
while(flag=='y')
{
cout<<"ENTER ITEMS(ENTER 0 TO END)"<<endl;
while(1)
{
cout<<"Cost of item: ";
cin>>cost;
if(cost==0)
break;
else
total+=cost;
}
cout<<fixed;
cout<<setprecision(2);
cout<<"Total: "<<total<<endl;
cout<<"Sales tax:
"<<Sales_tax(total)<<endl;
cout<<"Total after tax:
"<<total_new(total)<<endl;
cout<<"Again?(y/n):";
cin>>flag;
}
}
