home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / b / bt112.zip / TOTALS.BAS < prev    next >
BASIC Source File  |  1992-10-06  |  1KB  |  23 lines

  1. 10  ' totals.bas                                   
  2. 20  ' do cross totals on an array                  
  3. 30  DIM X(5,5)                                     
  4. 40  X(0,0) = 0                   ' grand totals    
  5. 50  FOR I = 1 TO 5                                 
  6. 60  X(I,0) = 0                                     
  7. 70     FOR J = 1 TO 5                              
  8. 80     X(I,J) = RND(1)*10                          
  9. 90     X(I,0) = X(I,0) + X(I,J)  ' line totals     
  10. 100    X(0,J) = X(0,J) + X(I,J)  ' column totals   
  11. 110    X(0,0) = X(0,0) + X(I,J)  ' grand total     
  12. 120    NEXT                                        
  13. 130 NEXT                                           
  14. 140 FOR I = 5 TO 0 STEP -1                         
  15. 150    IF I = 0 THEN PRINT "  "   ' extra space    
  16. 160    FOR J = 5 TO 0 STEP - 1                     
  17. 170    IF J = 0 THEN PRINT "  ";  ' extra row      
  18. 180    PRINT USING " ###.## ";X(I,J);              
  19. 190    NEXT                                        
  20. 200    PRINT                                       
  21. 210 NEXT                                           
  22.  
  23.