# Range array help

• ### Question

• I have to find the bug and put this into small basic and have no idea. help please?

Start

String name

Num score

Num NUM_TESTS = 4

Num NUM_RANGES = 5

Num RANGES [NUM_RANGES] = 90, 80, 70, 60, 0

String GRADES [NUM_RANGES] = “A”, “B”, “C”, “D”, “F”

num total = 0

num average

num sub

get name

while not eof

sub = 0

while sub  < NUM_TESTS

get score

total = total + score

sub = sub + 1

endwhile

Average = total / NUM_RANGES

Sub = 0

While average < RANGES[NUM_RANGES]

Sub = sub + 1

Endwhile

LetterGrade = GRADES [NUM_RANGES]

Print name, letterGrade

Get name

endwhile

stop

Thursday, December 24, 2015 11:18 PM

### Answers

• Perhaps ??:

```nTests = 4
arrRanges = "1=90;2=80;3=70;4=60;5=0;"
arrGrades = "1=A;2=B;3=C;4=D;5=F;"

TextWindow.Write("Name: ")
name = TextWindow.Read()

For t = 1 To nTests
TextWindow.Write("pts"+t+": ")
score = TextWindow.ReadNumber()
total = total + score
EndFor
average = total / nTests

n = 1
While average < arrRanges[n]
n = n + 1
EndWhile

letterGrade = arrGrades[n]
TextWindow.WriteLine(name +":  avg. "+ letterGrade)
```
• Proposed as answer by Thursday, December 31, 2015 12:33 PM
• Marked as answer by Friday, January 1, 2016 3:57 PM
Friday, December 25, 2015 11:20 AM

### All replies

• Perhaps ??:

```nTests = 4
arrRanges = "1=90;2=80;3=70;4=60;5=0;"
arrGrades = "1=A;2=B;3=C;4=D;5=F;"

TextWindow.Write("Name: ")
name = TextWindow.Read()

For t = 1 To nTests
TextWindow.Write("pts"+t+": ")
score = TextWindow.ReadNumber()
total = total + score
EndFor
average = total / nTests

n = 1
While average < arrRanges[n]
n = n + 1
EndWhile

letterGrade = arrGrades[n]
TextWindow.WriteLine(name +":  avg. "+ letterGrade)
```
• Proposed as answer by Thursday, December 31, 2015 12:33 PM
• Marked as answer by Friday, January 1, 2016 3:57 PM
Friday, December 25, 2015 11:20 AM
• Thank you, this is great!

Friday, December 25, 2015 10:56 PM