Quick help with strings

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • StickFest95
    New Member
    • Mar 2008
    • 1

    Quick help with strings

    I am working on a school project in which we are to make a basic cash register like program which determines the total price of several objects and adds 6 percent tax to specified items. What my problem is whenever it asks if you wish to add tax or not, it ignores if you say "y" for yes and does not add it. Could anyone help with this?

    [Code=vb]Module Module1

    Sub Main()
    Console.WriteLi ne("Welcome to unnamed outdoor gift shop on the Santa Monica Pier.")
    Console.ReadLin e()
    Dim decScore, decTax, decTotal As Decimal
    Dim intItems, intCount As Integer
    Dim strNugent As String
    Console.WriteLi ne("Enter the number of items")
    intItems = Console.ReadLin e()
    Do
    Console.WriteLi ne("Enter price")
    intCount = intCount + 1
    decScore = Console.ReadLin e()
    decTotal = decTotal + decScore
    Console.WriteLi ne("Is it taxable? y/n")
    strNugent = Val(Console.Rea dLine())
    If strNugent = "y" Then
    Console.WriteLi ne("Tax added")
    decTax = decTax + (decScore * 0.06)
    End If
    Loop While (intCount < intItems)

    Console.WriteLi ne("Total = " & (decTotal))
    Console.WriteLi ne("Press Enter to exit")
    Console.ReadLin e()
    End Sub
    End Module[/CODE]
    Last edited by debasisdas; Mar 11 '08, 04:50 AM. Reason: added code=vbnet tags
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Try to handle the ascii value of both Y and y and then check.

    Comment

    Working...