In: Computer Science
Sales tax is collected from buyers and remitted to the government. A retailer has to file a monthly sales tax report which lists the sales for the month and the amount of sales tax collected, at both the county and state levels. Develop a program that will input the total collections for a month, calculate the sales tax on the collections, and display the county and state taxes. Assume that states have a 4% sales tax and countries have a 5% sales tax. Here is a sample input/output dialog. How to Formulate the algorithm using pseudocode and top-down, stepwise refinement in c program ?
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
float sale_state, sale_country;
float sum=0;
float state_tax=0, country_tax=0;
printf("Sales in month in state\n"):
scanf("%f", &sale_state);
printf("Sales in month in country\n"):
scanf("%f", &sale_country);
state_tax = .4*sale_state;
country_tax = .5*sale_country;
printf("Tax collected in state level %d\n", state_tax):
printf("Tax collected in country level %d\n", country_tax):
return 0;
}
Top-down design:
1. Seller calculates how much sale he has made in the state.
2. Then he calculates 4% of his sales as sales tax for the state.
3. Seller calculates how much he has sold in the country.
4. Then he calculates 5% of the sales as country tax.