i am writing a grade cal. i have written the code to take five grade inputed by the user and / then by 5. how do i get unlitemed inputs and then / by that #.
Announcement
Collapse
No announcement yet.
muiltple inputs
Collapse
X
-
Basically you write these kinds of programs by prompting for grades, and ending when some special value is entered. eg in PB/CC you might write
Code:LOCAL Grade$ LOCAL nGrade AS LONG, iGrade AS LONG, tGrade AS LONG DO LINE INPUT "Grade", Grade$ IF Grade = "END" THEN PRINT USING$ ( # grades averaging ##.## processed.", ngrade, tGrade/nGrade) EXIT DO ELSE INCR nGrade iGrade = VAL (Grade$) tGrade = tGrade + iGrade PRINT USING$("#, grades processed so far", nGrade) END IF LOOP
MCMMichael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
-
There's many ways for doing this, but if you want to see the average as you enter them, you might try something like this:
Code:#COMPILE EXE FUNCTION PBMAIN () AS LONG LOCAL Grading AS STRING, Grades AS LONG, nbr AS LONG WHILE Grading <> "end" INCR nbr LOCATE 8, 39 : PRINT SPACE$(10) LOCATE 8, 10 : LINE INPUT "Enter a Grade or end to quit "; Grading Grades = Grades + VAL(Grading) LOCATE 10, 10 : PRINT "The Average grade for "; nbr; " Entries is "; Grades\nbr WEND END FUNCTION
Comment
Comment