Welcome to Dream.In.Code
Become an Expert!

Join 150,041 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,590 people online right now. Registration is fast and FREE... Join Now!




configuring function

 
Reply to this topicStart new topic

configuring function, configuring function

jrb47
11 Feb, 2008 - 09:34 PM
Post #1

New D.I.C Head
*

Joined: 21 Apr, 2007
Posts: 21


My Contributions
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

This post has been edited by jrb47: 12 Feb, 2008 - 12:03 AM
User is offlineProfile CardPM
+Quote Post

dygytalnomad
RE: Configuring Function
12 Feb, 2008 - 02:18 PM
Post #2

New D.I.C Head
*

Joined: 12 Feb, 2008
Posts: 6


My Contributions
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.
User is offlineProfile CardPM
+Quote Post

cprmnm
RE: Configuring Function
12 Feb, 2008 - 10:31 PM
Post #3

New D.I.C Head
*

Joined: 27 Dec, 2007
Posts: 2

QUOTE(dygytalnomad @ 12 Feb, 2008 - 03:18 PM) *

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.



hI friends can u help me to create a forum in asp.net



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


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 09:51PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month