By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,046 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

Sales Tax Calculation

P: 4
Hello! I am in a beginners computer class and I have a programming question that I need help with......PLEASE HELP!!!!!!

I have to write the following in Visual Basic.Net

Marie's Flower Shop would like to provide its front counter employees with a program that calculates the sales tax. The application should let the employee enter the amount of the customer's order and then calculate a 6% sales tax. After the employee enters the order amount and presses the enter key, the program should display the amount of the customer's order and the tax, followed by the total of the customer's order and tax added together. For example, an order amount of $100 should result in a tax of $6 and a total of $106.... This is what I have done but its not working!!! Can anyone try to figure out what I am doing wrong?

Sub Main()

Dim decOrder As Decimal
Dim decTax As Decimal

' Accept the order from the Console window
Console.WriteLine("Enter order in dollars: ")
decOrder = Console.ReadLine()

' Calculate the sales tax
decTax = 0.06 * (decOrder)

decTotal = (decOrder + decTax)

' Write the results to the Console Window
Console.WriteLine()
Console.WriteLine("The Total is " & decTotal)
Console.WriteLine("Press any key to continue.")


End Module
May 6 '07 #1
Share this Question
Share on Google+
6 Replies


Dököll
Expert 100+
P: 2,364
Hello! I am in a beginners computer class and I have a programming question that I need help with......PLEASE HELP!!!!!!

I have to write the following in Visual Basic.Net

Marie's Flower Shop would like to provide its front counter employees with a program that calculates the sales tax. The application should let the employee enter the amount of the customer's order and then calculate a 6% sales tax. After the employee enters the order amount and presses the enter key, the program should display the amount of the customer's order and the tax, followed by the total of the customer's order and tax added together. For example, an order amount of $100 should result in a tax of $6 and a total of $106.... This is what I have done but its not working!!! Can anyone try to figure out what I am doing wrong?

Expand|Select|Wrap|Line Numbers
  1.  
  2.     Sub Main()
  3.  
  4.         Dim decOrder As Decimal
  5.         Dim decTax As Decimal
  6.  
  7.         ' Accept the order from the Console window
  8.         Console.WriteLine("Enter order in dollars: ")
  9.         decOrder = Console.ReadLine()
  10.  
  11.         ' Calculate the sales tax
  12.         decTax = 0.06 * (decOrder)
  13.  
  14.         decTotal = (decOrder + decTax)
  15.  
  16.         ' Write the results to the Console Window
  17.         Console.WriteLine()
  18.         Console.WriteLine("The Total is " & decTotal)
  19.         Console.WriteLine("Press any key to continue.")
  20.  
  21.  
  22. End Module
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
Greetings, pinkstarr19!

Can you tell us a little more? You mentioned it is not working, but are you getting errors.

I added code tags on your behalf to allow a cleaner reading of your information.

Please stay tuned.

By the way, is using F8 via Debug mode available in .Net. Works with 6.0. If so, this might give you an idea where the code is not working.

Dököll
May 6 '07 #2

P: 4
[/code]Greetings, pinkstarr19!

Can you tell us a little more? You mentioned it is not working, but are you getting errors.

I added code tags on your behalf to allow a cleaner reading of your information.

Please stay tuned.

By the way, is using F8 via Debug mode available in .Net. Works with 6.0. If so, this might give you an idea where the code is not working.

Dököll


Greetings DoKoll

Thank you so much for trying to help me. I have worked on this problem for 6 hours today and cannot figure it out. The errors that I am getting are :
"Name 'decTotal' is not declared for Line 21 and 25"

I used the F8 key like you said, and that is what came up.

I really appreciate you trying to help me here. Programming is a little foreign to me....
May 7 '07 #3

P: 4
Greetings DoKoll

Thank you so much for trying to help me. I have worked on this problem for 6 hours today and cannot figure it out. The errors that I am getting are :
"Name 'decTotal' is not declared for Line 21 and 25"

I used the F8 key like you said, and that is what came up.

I really appreciate you trying to help me here. Programming is a little foreign to me....
May 7 '07 #4

P: 29
Hi I'm new to this as well. Have you tried adding...

Dim decTotal as Decimal

Hope this helps
May 7 '07 #5

Dököll
Expert 100+
P: 2,364
Hi I'm new to this as well. Have you tried adding...

Dim decTotal as Decimal

Hope this helps
Good job, Lazareth, I think that'll do it...

And you're quite welcome, pinkstarr19, be patient, a light will come on and you will nail this one down:-)
May 8 '07 #6

P: 4
This is what it looks like now after I made changes and it is still not working. I added the Dim decTotal As Decimal and it fixed the error. However, the calculator comes up but when I put the calculator amount of 100.00 and press enter, it automatically exits out of the calculator. Also, the cusor isn't at the top line where it says enter order in dollars. Thank you for checking on this...

Sub Main()

Dim decOrder As Decimal
Dim decTax As Decimal
Dim decTotal As Decimal

' Accept the order from the Console window
Console.WriteLine("Enter order in dollars: ")
decOrder = Console.ReadLine()

' Calculate the sales tax
decTax = 0.06 * (decOrder + decTax)

decTotal = (decOrder + decTax)

' Write the results to the Console Window
Console.WriteLine()
Console.WriteLine("The Total is " & decTotal)
Console.WriteLine("Press any key to continue.")
End Sub

End Module
May 8 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.