Announcement

Collapse
No announcement yet.

muiltple inputs

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • muiltple inputs

    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 #.

  • #2
    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
    It could use a litt... er, a lot of refinement

    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Originally posted by David Sherwood View Post
      how do i get unlitemed inputs ...
      Search me. Start with a spellchecker?

      Comment


      • #4
        Set it up that the user enters grades seperated by whatever delimiter you specify, then [ENTER] at the end of line when done. Then use ParseCount and Parse to take it all apart, divide by the # delimiters, etc.
        Fred
        "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

        Comment


        • #5
          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

          Working...
          X