In: Computer Science
Step 1: Examine the following algorithm.
Step 2: Given a total sales of $27,097, answer the following:
The calculated state tax =1083.88
The calculated county tax =541.94
The calculated total tax=1625.82
Below are variable names and its purpose
1)Declare Real total Sales-Stores total sales the user inputs
2)Declare real countyTax-Stores county tax
3)Declare real stateTax-Stores state tax
4)Declare real totalTax-Stores total tax
Step 2: Given the major task involved in this program, what modules might you consider including.We Describe the purpose of each module
1)Module inputData () - Allows the user to enter required user input
2) Module calcCounty () - Calc county tax
3)Module calcState () - Calc state tax
4)Module calcTotal () - Calc total tax
5)Module printTax () - Print tax
Step 3: Complete the pseudocode by writing the missing lines Also, when writing your modules and making calls, be sure to pass necessary variables as arguments and accept them as reference parameters if they need to be modified in the module.
Module main ()
//Declare local variables
Declare Real totalSales
Declare Real countyTax
Declare real stateTax
Declare Real totalTax
//Function calls
Call inputData(totalSales)
Call calcCounty(totalSales, countyTax)
Call calcState (totalSales, stateTax)
Call calcTotal (totalSales, countyTax, stateTax, calctotal)
End Module
//this module takes in the required user input
Module inputData(Real Ref totalSales)
Display “Enter the total sales for the month.”
Input totalSales
End Module
//this module calculates county tax
//totalSales can be a value parameter because it is not
//changed in the module.
//countyTax must be a reference parameter because it is
//changed in the module
Module calcCounty(Real totalSales, Real Ref countyTax)
countyTax = totalSales * .02
End Module
//this module calculates state tax
calcCounty(Real totalSales, Real Ref totalTax)
totalTax = totalSales * .06
End Module
//this module calculates total tax
Module calctotal real ref totalSales real stateTax real countyTax
calcCounty(Real totalSales, Real Ref totalTax)
totalTax = totalSales * .06
End Module
//this module prints the total, county, and state tax
Module
End Module
/* Description: This program calculates the total price which includes sales tax */ import java.util.Scanner; public class SalesTax { public static void main(String[] args) { //identifier declarations final double TAX_RATE = 0.055; // Sales Tax Rate CONSTANT double price; //price of the item (input) double tax; //tax (calculated using price * TAX_RATE) double total; // total owed (calculated using price + tax) String item; // name of the item purchased //create a Scanner object to read from the keyboard Scanner keyboard = new Scanner(System.in) //display prompts and get input System.out.print("Item description: "); // prompt for item item = key.nextLine(); // read & store item as entered by user System.out.print("Item price: $"); // prompt for price price = keyboard.nextDouble(); // read & store price //calculations tax = price * TAX_RATE; // calculate & store value for tax total = price + tax; // calculate & store value for total //output results System.out.println("Item purchased: " + item); out.println("Price $" + price); System.out.println("Tax $" + tax); system.out.println("Total $" + total); } }