Solved

Vb.net calculation problem.

Posted on 2009-03-31
269 Views
How am i supposed to set this up? I've tried using what I've got but it won't calculate what I need to properly. Breakdown:
I have a program were I'm supposed to calculate books read and award points
based on a certain amount of books read by the reader. In the place of some numbers I used constants.
1-3 books = 10pts ea.
next 3 books = 15pts ea.
6 or more = 20pts ea.
``````'Declared Constants
Const BOOKS_READ1Integer As Integer = 10
Const BOOKS_READ2Integer As Integer = 15
Const BOOKS_READ3Integer As Integer = 20
Const MAX_BOOKS_ALLOWED_READInteger As Integer = 10000

'Declared Variables

Private Function calculatePointsDataType(ByVal bookValue As String) As Integer
Dim bookPoints As Integer

Try

If numberBooksRead <= 1 And 3 Then
ElseIf numberBooksRead < 3 And = 6 Then

End If
Catch ex As Exception
End Try

Return bookPoints
End Function
``````
0
Question by:shaunareno
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

Author Comment

ID: 24035832
Revised Question:
not the calculation but, the logic is what I'm having trouble with.

0

LVL 84

Expert Comment

ID: 24036112
what are you trying to do when you say
And 3
?
what are you trying to do when you say
And = 6

would be interpreted under customary precedence rules as
whereas you probably meant
0

LVL 86

Accepted Solution

Mike Tomlinson earned 500 total points
ID: 24036207
It seems like from your line here:

That you could instead loop thru and just tally up the points as you go:

Private Function CalculateBookPoints() As Integer
Dim points As Integer = 0
For i As Integer = 1 To numberBooksRead
If i <= 3 Then
ElseIf i <= 6 Then
Else
End If
Next
Return points
End Function
0

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Starting up a Project
Suggested Courses
Course of the Month2 days, 17 hours left to enroll