Question

In: Computer Science

Project 7-6: Sales Tax Calculator Create a program that uses a separate module to calculate sales...

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

  • The program should only accept numbers that are greater than 0.
  • Use the console.h and console.cpp files described in chapter 7 to validate user entries. That way, the user can’t crash the program by entering invalid data.
  • The sales tax rate should be 6% of the total.
  • Use a header file to declare two functions. One should accept the total of the items and return the tax amount. The other should accept the total of the items and return the total after tax has 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.

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.

Solutions

Expert Solution

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;
}
}


Related Solutions

In this project you will create a basic console based calculator program. The calculator can operate...
In this project you will create a basic console based calculator program. The calculator can operate in two modes: Standard and Scientific modes. The Standard mode will allow the user to perform the following operations: (+, -, *, /) add, subtract, multiply, and divide The Scientific mode will allow the user to perform the same functionality as the Standard add, subtract, multiply, and divide (+, -, *, / ) plus the following: sin x, cos x, tan x. (sin x,...
Module 6 Project A: Stereo Payment Calculator You have just purchased a stereo system that cost...
Module 6 Project A: Stereo Payment Calculator You have just purchased a stereo system that cost $1,000 on the following credit plan: no down payment, an interest rate of 18% per year (and hence 1.5% per month), and monthly payments of $50. The monthly payment of $50 is used to pay the interest and whatever is left is used to pay part of the remaining debt. Debt0= 1000 Interestn = Debtn*0.015 Principaln = 50 - Interestn Debtn+1 = Debtn -...
C++ Program -------------------- Project 5-1: Monthly Sales Create a program that reads the sales for 12...
C++ Program -------------------- Project 5-1: Monthly Sales Create a program that reads the sales for 12 months from a file and calculates the total yearly sales as well as the average monthly sales. Console Monthly Sales COMMAND MENU m - View monthly sales y - View yearly summary x - Exit program Command: m MONTHLY SALES Jan        14317.41 Feb         3903.32 Mar         1073.01 Apr         3463.28 May         2429.52 Jun         4324.70 Jul         9762.31 Aug        25578.39 Sep         2437.95 Oct         6735.63 Nov          288.11 Dec         2497.49...
Tip Calculator Instructions For this project you are to create a tip calculator that will take...
Tip Calculator Instructions For this project you are to create a tip calculator that will take a decimal/or non decimal amount and calculate the different tip values of that amount: 10% 15% 20% And display them appropriately. The values will be set to two decimal places. If you have an empty value, then a message will display informing the user of such. When the device is rotated the error message or tip information must continue to be displayed. in Android/Java
Complete each of the programs here. Create a separate Netbeans project for each program using the...
Complete each of the programs here. Create a separate Netbeans project for each program using the name I specified. Create a single java main class for each of the programs using the filename I specified. Task 1: (5 points) Project name: CtoFConverter Main file name: TempConverter.java A program that converts an inputted temperature in C and provides the equivalent temperature in F. Hint: Google is your friend! Given C, solve for F. Again, check for a valid input value and...
Complete these steps to write a simple calculator program: 1. Create a calc project directory 2....
Complete these steps to write a simple calculator program: 1. Create a calc project directory 2. Create a mcalc.c source file containing five functions; add, sub, mul, div, and mod; that implement integer addition, subtraction, multiplication, division, and modulo (remainder of division) respectively. Each function should take two integer arguments and return an integer result. 3. Create a mcalc.h header file that contains function prototypes for each of the five functions implemented in mcalc.c. 4. Create a calc.c source file...
Create a Python program that will calculate the user’s net pay based on the tax bracket...
Create a Python program that will calculate the user’s net pay based on the tax bracket he/she is in. Your program will prompt the user for their first name, last name, their monthly gross pay, and the number of dependents. The number of dependents will determine which tax bracket the user ends up in. The tax bracket is as followed: 0 – 1 Dependents : Tax = 20% 2 – 3 Dependents : Tax = 15% 4+ Dependents :    Tax...
I need Calculator project : A complex number calculator program that allows the user to do...
I need Calculator project : A complex number calculator program that allows the user to do either addition, subtraction, multiplication or division where a complex number is a number of the form a + bi where a and b are real numbers and i equals √ −1. 1. It must consist of at least five functions excluding the main function. 2. There should be a function for each operation. Each of these functions should handle checking the validity of its...
7. Average Rainfall Design a program that uses nested loops to collect data and calculate the...
7. Average Rainfall Design a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the number...
Calculate the standard deviation for the following data: 13, 7, 7, 7, 7, 6, 6, 5,...
Calculate the standard deviation for the following data: 13, 7, 7, 7, 7, 6, 6, 5, 5, 4, 4, 3
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT