Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

super noob, need help!

ofnir1ofnir1 Member Posts: 9
Okay, first off, I'm a super noob, so please don't flame! So that there is the program that im trying to write. Pretty basic, though I'm apparently doing something wrong. This program will correctly run statment number(s) 50 and 55 but if I try to put a number in, when i run the progarm, such as 70 or 80 or 90 I get the same answer in 100. D. I won't get A, B, C only D, allthough "f" will work if I input any number below 59. Any help would be appreciated and I hope I made that clear enough!

20 REM PROBLEM #6 THIS PROGRAM COMPUTES YOUR EQUIVALENT LETTER GRADE BASED UPON NUMERICAL SCORES.
30 PRINT "PLEASE ENTER YOUR NUMERICAL GRADE"
40 INPUT "WHAT IS YOUR NUMERICAL GRADE";G
50 IF G < 59 THEN G$ = "F" : GOTO 100
55 IF 60 < G < 69 THEN G$ = "D" : GOTO 100
60 IF 70 < G < 79 THEN G$ = "C" : GOTO 100
65 IF 80 < G < 89 THEN G$ = "B" : GOTO 100
70 IF 90 < G < 100 THEN G$ = "A" : GOTO 100
100 PRINT "YOUR GRADE IS AS FOLLOWS:" ;G$
120 PRINT "DO YOU WANT TO CONTINUE"
130 INPUT "DO YOU WANT TO CONTINUE (YES OR NO)" ; R$
131 IF R$="YES" THEN GOTO 30
132 IF R$="NO" THEN GOTO 150
150 END

Comments

  • zibadianzibadian Member Posts: 6,349
    : Okay, first off, I'm a super noob, so please don't flame! So that
    : there is the program that im trying to write. Pretty basic, though
    : I'm apparently doing something wrong. This program will correctly
    : run statment number(s) 50 and 55 but if I try to put a number in,
    : when i run the progarm, such as 70 or 80 or 90 I get the same answer
    : in 100. D. I won't get A, B, C only D, allthough "f" will work if I
    : input any number below 59. Any help would be appreciated and I hope
    : I made that clear enough!
    :
    : 20 REM PROBLEM #6 THIS PROGRAM COMPUTES YOUR EQUIVALENT LETTER GRADE
    : BASED UPON NUMERICAL SCORES.
    : 30 PRINT "PLEASE ENTER YOUR NUMERICAL GRADE"
    : 40 INPUT "WHAT IS YOUR NUMERICAL GRADE";G
    : 50 IF G < 59 THEN G$ = "F" : GOTO 100
    : 55 IF 60 < G < 69 THEN G$ = "D" : GOTO 100
    : 60 IF 70 < G < 79 THEN G$ = "C" : GOTO 100
    : 65 IF 80 < G < 89 THEN G$ = "B" : GOTO 100
    : 70 IF 90 < G < 100 THEN G$ = "A" : GOTO 100
    : 100 PRINT "YOUR GRADE IS AS FOLLOWS:" ;G$
    : 120 PRINT "DO YOU WANT TO CONTINUE"
    : 130 INPUT "DO YOU WANT TO CONTINUE (YES OR NO)" ; R$
    : 131 IF R$="YES" THEN GOTO 30
    : 132 IF R$="NO" THEN GOTO 150
    : 150 END
    :
    :
    You cannot check 2 conditions in the way you do:
    [code]
    : 55 IF [b][red]60 < G < 69[/red][/b] THEN G$ = "D" : GOTO 100
    [/code]
    The solution is quite simple: at line 55 you already know that G is 60 or larger (since 50 checked that), so you don't need to check that again. In 55 you can simply check if G is less than 69.
    Then in line 60, you don't need to check if G is less than 70, since you already checked that in line 55. Thus again you can remove that check. etc.
Sign In or Register to comment.