Problem Radomizer

M_1_s_t_1_c

New member
Joined
Oct 8, 2008
Messages
4
Programming Experience
1-3
I have a test coming up and I have been assigned several practice problems but this one is a different from what we have been over.

Need to create a problem randomizer
-1st Graders receive addition and subtraction problems using numbers 1-10
-2nd Graders receive addition and subtraction problems using numbers 10-99
-They have not learned negative numbers yet

The program needs to keep up with how many problems have been answered correctly and incorrectly. The student should also have a many chances needed to answer the problem correctly (I figured have it where it calculates and then displays the results after the student is finished.)

I figured out I need to use variableName = ranGenerator.Next(1, 11) and variableName = ranGenerator.Next(10, 100)

I don't need the full code...I'm just lost and need a starting point:confused:
 
I would start off by creating a seperate class to store your numbers and whether the question has been answered correctly or not.

If you haven't seen anything like this in class I'm assuming the teacher wants you to create parallel arrays to keep track of the data.

VB.NET:
Public Class Question

	Private _FirstNumber As Integer
	Public Property FirstNumber() As Integer
		Get
			Return _FirstNumber
		End Get
		Set(ByVal value As Integer)
			_FirstNumber = value
		End Set
	End Property

	Private _SecondNumber As Integer
	Public Property SecondNumber() As Integer
		Get
			Return _SecondNumber
		End Get
		Set(ByVal value As Integer)
			_SecondNumber = value
		End Set
	End Property

	Private _IsCorrect As Boolean
	Public Property NewProperty() As Boolean
		Get
			Return _IsCorrect
		End Get
		Set(ByVal value As Boolean)
			_IsCorrect = value
		End Set
	End Property

End Class

Dimension a class level list to store your questions

VB.NET:
Dim Test As New List(Of Question)

Generate 10 questions and add them to the list you created. The IsCorrect Boolean field you created will default to False. Modify the code to generate random numbers for 1st or 2nd grade.

VB.NET:
		Dim rand As New Random()

		For i As Integer = 0 To 9

			Dim int(2) As Integer
			Dim q As New Question

			Do Until int(0) > int(1)
				int(0) = rand.Next(10, 100)
				int(1) = rand.Next(10, 100)
			Loop

			q.FirstNumber = int(0)
			q.SecondNumber = int(1)

			Test.Add(q)
		Next

From here you can check if Test.Item(i).FirstNumber - Test.Item(i).SecondNumber = TheirAnswer and set Test.Item(i).IsCorrect() = True on the questions they answered correctly.

This should give you a good place to start writing your problem. Best of luck on your test.
 
Thanks a lot man...my test got pushed back a couple more days and I have been working on the code some. Is there anyway you could give me the rest of the code? Im just trying to get everything together so I know how the codes are done. If not its cool nobody likes writing code for someone else lol.
 
Back
Top