Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- Const NUM_CARROTS As Integer = 10000
- Const OFFSET_WIDTH As Single = 1254.8F
- Const PLANT_INTERVAL As Single = 1.25F
- Dim carrot_pos(NUM_CARROTS - 1) As Single
- Sub plant_carrot(ByVal idx As Integer)
- carrot_pos(idx) = OFFSET_WIDTH + idx * PLANT_INTERVAL
- End Sub
- Sub plant_carrots()
- For i = 0 To NUM_CARROTS - 1
- plant_carrot(i)
- Next
- End Sub
- Sub print_carrots()
- For i = 0 To NUM_CARROTS - 1
- Console.WriteLine("Carrot {0} goes to {1:0.00} inches\n", i, carrot_pos(i))
- Next
- End Sub
- Function is_planted_ok(ByVal idx As Integer) As Boolean
- Return Math.Round(carrot_pos(idx) - carrot_pos(idx - 1), 2) = PLANT_INTERVAL
- End Function
- Sub test_carrots()
- Dim num_bad As Integer = 0
- For i = 1 To NUM_CARROTS - 1
- If Not is_planted_ok(i) Then
- Console.WriteLine("The carrot {0} is planted incorreclty!!!", i)
- num_bad += 1
- End If
- Next
- If num_bad = 0 Then
- Console.WriteLine("All carrots placed well!!!!")
- Else
- Console.WriteLine("{0} of {1} carrots placed incorrectly... : (", num_bad, NUM_CARROTS)
- End If
- End Sub
- Sub Main()
- plant_carrots()
- 'print_carrots()
- test_carrots()
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement