Hey guys, I'm having trouble with my program, It suppose to take in a number as "totalSales" from the user and calculate the county and state tax and then calculate the total between the two. Then it displays all three answers( total, state, county) to console. But when I put in 4,545 as a number(totalSales) the county tax shows 4,545 instead of 90.9 that is suppose to be. I can't figure out whats going on!! The state tax works like it supposed to, but county tax don't and their the same besides the variable name. Oh by the way this is written in VB!!
thanks for any help you may have!!!
tj
p.s. I have to turn it in by Sunday night!!
works better like this:
Module Module1
Sub Main()
Dim totalSales As Double
Dim countyTax As Double
Dim stateTax As Double
Dim totalTax As Double
inputSales(totalSales)
calcCounty(totalSales, countyTax)
calcState(totalSales, stateTax)
calcTotal(countyTax, stateTax, totalTax)
printTax(totalSales, countyTax, stateTax)
Console.ReadLine()
End Sub
'FUNCTIONS
'inputData Function
Sub inputSales(ByRef totalSales)
Console.WriteLine("Enter the total sales for the month")
totalSales = Console.ReadLine()
End Sub
'calcCounty Function
Sub calcCounty(totalSales, ByRef countyTax)
countyTax = totalSales * 0.02
End Sub
'calcState Function
Sub calcState(totalSales, ByRef stateTax)
stateTax = totalSales * 0.04
End Sub
'totalTax Fucntion
Sub calcTotal(ByRef totalTax, stateTax, countyTax)
totalTax = countyTax + stateTax
End Sub
'PrintTax Function
Sub printTax(countyTax, stateTax, totalTax)
Console.WriteLine("The county tax is... " & countyTax)
Console.WriteLine("The state tax is... " & stateTax)
Console.WriteLine("The total tax for both State and County is... " & totalTax)
End Sub
End Module
thanks for any help you may have!!!
tj
p.s. I have to turn it in by Sunday night!!
works better like this:
Module Module1
Sub Main()
Dim totalSales As Double
Dim countyTax As Double
Dim stateTax As Double
Dim totalTax As Double
inputSales(totalSales)
calcCounty(totalSales, countyTax)
calcState(totalSales, stateTax)
calcTotal(countyTax, stateTax, totalTax)
printTax(totalSales, countyTax, stateTax)
Console.ReadLine()
End Sub
'FUNCTIONS
'inputData Function
Sub inputSales(ByRef totalSales)
Console.WriteLine("Enter the total sales for the month")
totalSales = Console.ReadLine()
End Sub
'calcCounty Function
Sub calcCounty(totalSales, ByRef countyTax)
countyTax = totalSales * 0.02
End Sub
'calcState Function
Sub calcState(totalSales, ByRef stateTax)
stateTax = totalSales * 0.04
End Sub
'totalTax Fucntion
Sub calcTotal(ByRef totalTax, stateTax, countyTax)
totalTax = countyTax + stateTax
End Sub
'PrintTax Function
Sub printTax(countyTax, stateTax, totalTax)
Console.WriteLine("The county tax is... " & countyTax)
Console.WriteLine("The state tax is... " & stateTax)
Console.WriteLine("The total tax for both State and County is... " & totalTax)
End Sub
End Module
Attachments
Last edited: