CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Stuck on VB Homework (NOT LOOKING FOR JUST AN ANSWER)

  1. #1
    Join Date
    Mar 2010
    Posts
    3

    Stuck on VB Homework (NOT LOOKING FOR JUST AN ANSWER)

    I was assigned a homework problem that states:

    **************************
    Construct a structure chart, as well as a flowchart and pseudocode, for the following problem. Assume that each input record contains a taxpayer’s name, the value of a personal property belonging to the taxpayer, and a code defining the type of personal property owned. Each type of property is taxed at a unique rate. The codes, property types, and tax rates follow:

    CODE PROPERTY TYPE TAX RATE
    1 Bike 2 percent of value
    2 Car 4 percent of value
    3 Truck 5 percent of value

    Your program is to compute the tax for each property and to output a line specifying the taxpayer’s name, value of property, and tax. The program should output counts of the numbers of bikes, cars, and trucks for which taxes are computed, which appropriate labels. Include a report heading and column headings, as well as a page number on every page, with 55 detail lines per page. Also include an initial IF and a modular design. Output an error message if the input contains an invalid code value. Assume a code of 0 indicates the end of the input file.
    ******************************

    My question is why doesn't my program add up the amount of codes each time you enter it? Also, why does it say there is a total of 1 input for all codes? Also, the tax is not inputting but if i put the tax = propval * tr in each module then it will display the taxes for ALL the modules instead of just the module it should be going to. Thats another thing I'm not sure about is when it asks for code in the console and the user inputs 1, 2 or 3, how do I make it go to that module and only that module?

    I am using VB 2010 express and creating a console application. Thank you very much for your guys help and here is the code:



    Module cisp300assignt9
    Dim CD As Integer
    Dim CD1 As Integer
    Dim CD2 As Integer
    Dim CD3 As Integer
    Dim CD1COUNT As Integer
    Dim CD2COUNT As Integer
    Dim CD3COUNT As Integer
    Dim CDINVLCOUNT As Integer
    Dim CDINVL As Integer
    Dim NAME As String
    Dim TR As Decimal
    Dim TAX As Decimal
    Dim PROPVAL As Integer


    Sub Main()
    Console.WriteLine("Enter Taxpayer's Name: ")
    NAME = Console.ReadLine()

    Console.WriteLine("Enter Property Value: ")
    PROPVAL = Console.ReadLine()

    Console.Write("Enter Code: ")
    CD = Console.ReadLine()

    If CD = 0 Then
    Console.Write("End of Data")
    Else
    Do While CD > 0
    Call INITIALIZATION()
    Call COMPUTE()
    Call CODE1()
    Call CODE2()
    Call CODE3()
    Call CODEINVAL()

    Console.WriteLine(" NAME IS " & NAME & " PROPERTY VALUE IS " & _
    PROPVAL & " TAX IS " & TAX & " NUMBER OF BIKES IS " & _
    CD1 & " NUMBER OF CARS " & CD2 & " NUMBER OF TRUCKS " & _
    CD3)
    Console.WriteLine("TOTAL NUMBER OF CODE 1 RECORDS IS: " & CD1COUNT & "TOTAL NUMBER OF CODE 2 RECORDS IS: " & CD2COUNT & _
    "TOTAL NUMBER OF CODE 3 RECORDS IS: " & CD3COUNT & "TOTAL NUMBER OF INVALID CODES: " & CDINVLCOUNT)
    Console.WriteLine("Enter Taxpayer's Name: ")
    NAME = Console.ReadLine()

    Console.WriteLine("Enter Property Value: ")
    PROPVAL = Console.ReadLine()

    Loop
    End If
    End Sub

    Sub INITIALIZATION() 'B000
    CD1COUNT = 0
    CD2COUNT = 0
    CD3COUNT = 0
    CDINVLCOUNT = 0
    End Sub

    Sub COMPUTE() ' B010
    If CD = 0 Then
    Console.WriteLine("End of Data")
    Else
    TAX = PROPVAL * TR
    End If

    End Sub

    Sub CODE1() 'C000
    CD1COUNT = CD1COUNT + 1
    TR = 0.02
    End Sub

    Sub CODE2() 'C010
    CD2COUNT = CD2COUNT + 1
    TR = 0.04

    End Sub

    Sub CODE3() 'C020
    CD3COUNT = CD3COUNT + 1
    TR = 0.05

    End Sub

    Sub CODEINVAL() 'C030
    CDINVLCOUNT = CDINVLCOUNT + 1
    TR = 0
    End Sub

    End Module

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Stuck on VB Homework (NOT LOOKING FOR JUST AN ANSWER)

    Go back and add CODE TAGS, so we can read the code.

    Like this:
    Code:
    Module cisp300assignt9
    Dim CD As Integer
    Dim CD1 As Integer
    Dim CD2 As Integer
    Dim CD3 As Integer
    Dim CD1COUNT As Integer
    Dim CD2COUNT As Integer
    Dim CD3COUNT As Integer
    Dim CDINVLCOUNT As Integer
    Dim CDINVL As Integer
    Dim NAME As String
    Dim TR As Decimal
    Dim TAX As Decimal
    Dim PROPVAL As Integer
    
    
    Sub Main()
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Mar 2010
    Posts
    3

    Re: Stuck on VB Homework (NOT LOOKING FOR JUST AN ANSWER)

    Code:
    Module cisp300assignt9
    Dim CD As Integer
    Dim CD1 As Integer
    Dim CD2 As Integer
    Dim CD3 As Integer
    Dim CD1COUNT As Integer
    Dim CD2COUNT As Integer
    Dim CD3COUNT As Integer
    Dim CDINVLCOUNT As Integer
    Dim CDINVL As Integer
    Dim NAME As String
    Dim TR As Decimal
    Dim TAX As Decimal
    Dim PROPVAL As Integer
    
    
    Sub Main()
    Console.WriteLine("Enter Taxpayer's Name: ")
    NAME = Console.ReadLine()
    
    Console.WriteLine("Enter Property Value: ")
    PROPVAL = Console.ReadLine()
    
    Console.Write("Enter Code: ")
    CD = Console.ReadLine()
    
    If CD = 0 Then
    Console.Write("End of Data")
    Else
    Do While CD > 0
    Call INITIALIZATION()
    Call COMPUTE()
    Call CODE1()
    Call CODE2()
    Call CODE3()
    Call CODEINVAL()
    
    Console.WriteLine(" NAME IS " & NAME & " PROPERTY VALUE IS " & _
    PROPVAL & " TAX IS " & TAX & " NUMBER OF BIKES IS " & _
    CD1 & " NUMBER OF CARS " & CD2 & " NUMBER OF TRUCKS " & _
    CD3)
    Console.WriteLine("TOTAL NUMBER OF CODE 1 RECORDS IS: " & CD1COUNT & "TOTAL NUMBER OF CODE 2 RECORDS IS: " & CD2COUNT & _
    "TOTAL NUMBER OF CODE 3 RECORDS IS: " & CD3COUNT & "TOTAL NUMBER OF INVALID CODES: " & CDINVLCOUNT)
    Console.WriteLine("Enter Taxpayer's Name: ")
    NAME = Console.ReadLine()
    
    Console.WriteLine("Enter Property Value: ")
    PROPVAL = Console.ReadLine()
    
    Loop
    End If
    End Sub
    
    Sub INITIALIZATION() 'B000
    CD1COUNT = 0
    CD2COUNT = 0
    CD3COUNT = 0
    CDINVLCOUNT = 0
    End Sub
    
    Sub COMPUTE() ' B010
    If CD = 0 Then
    Console.WriteLine("End of Data")
    Else
    TAX = PROPVAL * TR
    End If
    
    End Sub
    
    Sub CODE1() 'C000
    CD1COUNT = CD1COUNT + 1
    TR = 0.02
    End Sub
    
    Sub CODE2() 'C010
    CD2COUNT = CD2COUNT + 1
    TR = 0.04
    
    End Sub
    
    Sub CODE3() 'C020
    CD3COUNT = CD3COUNT + 1
    TR = 0.05
    
    End Sub
    
    Sub CODEINVAL() 'C030
    CDINVLCOUNT = CDINVLCOUNT + 1
    TR = 0
    End Sub
    
    End Module

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)