QUOTE(jrb47 @ 11 Feb, 2008 - 10:34 PM)

I am working on a programming assignment.
I have a few questions as the book is ambiguous to say the least.
PROJECT: create page that allows purchase of variable quantity of two items, totals and then figures tax. I have gotten as far as figuring the subtotal of the individual items. The problem I am having is getting started with the function for figuring the tax and then the total sale.
Here is the code
CODE
<script language="vb" runat="server">
Sub Page_Load()
Dim pinkfloydshirt As Decimal
Dim wowhat As Decimal
Dim subtotal As Decimal
Dim subtotal2 As Decimal
Dim subtotal3 As Decimal
Dim totalsale AS Decimal
Dim tax As decimal
tax = Findtax(subtotal3)
pinkfloydshirt = 14.99
wowhat = 8.99
totalsale = subtotal3 + tax
Message1.text = "Pink Floyd Tshirt Cost $" & pinkfloydshirt
Message2.text = "Wow Hat Cost $" & wowhat
if shirtquantity.Text <> "" then
subtotal = shirtquantity.text * pinkfloydshirt
Message3.text = subtotal
subtotal3 = subtotal
end if
if hatquantity.Text <> "" then
subtotal2 = hatquantity.text * wowhat
Message4.text = subtotal2
subtotal3 = subtotal3 + subtotal2
Message5.text = "your subtotal for order is $" & subtotal3
Message7.text = "sales tax is $" & tax
Message6.text = "Total order is $" & totalsale
end if
End Sub
Function Findtax(subtotal3 as decimal) As Decimal
Dim tax As decimal
tax = subtotal3 * .08
return tax
End Function
</script>
<html>
<head>
<title>Sample Function Page</title>
</head>
<body>
<h2>Thank you for Shopping at Shirts and More.</h2>
<form runat="server">
<asp:label id="message1" runat="server"/> <br/>
Quantity ordered
<asp:textbox id="shirtquantity" runat="server" /><br />
<asp:label id="message3" runat="server"/> <br/><br />
<asp:label id="message2" runat="server"/> <br/>
Quantity ordered
<asp:textbox id="hatquantity" runat="server" /><br />
<asp:label id="message4" runat="server"/> <br/><br />
<asp:label id="message5" runat="server"/> <br/>
<asp:label id="message7" runat="server"/> <br/>
<asp:label id="message6" runat="server"/> <br/><br />
<input type="Submit">
</form>
</body>
</html>
Thanks for any help
Jess
You probably can't find the tax and subtotal or grand total before you find the subtotal
So this should be the last line of code before you find the grand total
tax = Findtax(subtotal3)
CODE
if shirtquantity.Text <> "" then
subtotal = shirtquantity.text * pinkfloydshirt
Message3.text = subtotal
subtotal3 = subtotal
end if
if hatquantity.Text <> "" then
subtotal2 = hatquantity.text * wowhat
Message4.text = subtotal2
subtotal3 = subtotal3 + subtotal2
Message5.text = "your subtotal for order is $" & subtotal3
tax = FindTax(subtotal3)
Message7.text = "sales tax is $" & tax
Message6.text = "Total order is $" & totalsale
end if
You need to do the totalsales around the area where you figure out tax too.
HTH.