Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Your site was well structured and I found what I was looking for in about 2 minutes. I am looking forward to participating with you in the future..."

Geography

Where in the world do Tek-Tips members come from?

Fortran 95 Programming help

6berry (Programmer)
23 Apr 12 8:20
Hi, I'm new here and I need some help with programming in Fortran 95. This is what I need to do but im not sure how to do it


Write an application that tracks scoring statistics for a basketball team of 15 players.  The team plays a total of 10 games.  The application must read the basketball statistics from a file and perform the following (refer to table on next page).
•    Display each player's points for each game
•    Display each player's average points per game
•    Display the team's total points per game
•    Display the team's average points per game
Use a two dimensional array (GameStats, 15 x 10) to store the basketball statistics.  The player number and game number should be used as indexes into the array (i.e., both indexes start at 1).  

The player statistics are stored in a file named "BballStats.txt".  The format of each line in the file is as follows.  

<Player Number> <Game Number> <Points Scored>


The range of each field is defined below.

PlayerNumber: 1 – 15
GameNumber: 1 – 10
PointsScored: 0 - 100

Rewrite the application described in Project 3 by using a module, BBallStatsModule, that contains two subroutines.  The first subroutine will calculate the total scores for all of the games.  The second subroutine will calculate the average points scored for all of the players.  The module must be in a separate file.  Each subroutine is described below
•    calculateTotalPoints(gameStats, totalPointsarr, numRows, numCols)
o    gameStats: a two-dimensional array intent IN
o    totalPointsArr: - a one-dimensional array with intent INOUT
o    numRows: - an integer, representing the number of players in the gameStats array, intent IN
o    numCols: - an integer, representing the number of games in the gameStats and totalPointsArr array, intent IN

•    calculateAvgPoints(gameStats, avgPointsArr, numRows, numCols)
o    gameStats: a two-dimensional array intent IN
o    avgPointsArr - a one-dimensional array with intent INOUT
o    numRows: - an integer, representing the number of players in the gameStats and avgPointsArr array, intent IN
o    numCols: - an integer, representing the number of games in the gameStats array, intent IN

I have some of the program written but i dont think its correct so  if anyone could help me out that would be great!
gummibaer (Programmer)
23 Apr 12 8:27
What would be your program ?
You know, we hate to do student's homework here ...

Norbert

The optimist believes we live in the best of all possible worlds - the pessimist fears this might be true.

6berry (Programmer)
23 Apr 12 12:09
Here is what I have of the program so far:

PROGRAM Project4

  USE bballstatsmodule

  IMPLICIT NONE
  REAL, DIMENSION (10:15) :: a
  INTEGER :: ioerror, k, j
  REAL :: sum
  INTEGER :: nbplayer, nbgame, nbentry
  INTEGER :: player, game, points


  nbplayer=15
  nbgame=10
  nbentry = nbplayer * nbgame

  OPEN(UNIT=69, FILE='bballstats2.txt', STATUS='OLD', ACTION='READ', IOSTAT=ioerror)
  DO k=1,nbplayer
    DO j=1,nbgame
      READ(69,21) points
      21 FORMAT (F2.0, F3.0)
      bballstats(nbplayer,nbgame)=points
  ENDDO

  WRITE (*,*) 'Welcome to the Basketball Statistics Processing System'
  WRITE (*,*) 'Game Statistics Summary'

  CALL calculatetotalpoints

  DO 1 nbgame=1,10
    DO 1 nbplayer=1,15
    READ (*,*) a(10:15)
  1 CONTINUE

  DO 2 nbgame=1,10
    DO 2 nbplayer=1,15
    WRITE (*,*) a(10:15)
  2 CONTINUE

  WRITE (*,*) 'Game Totals'

  DO 3 nbgame=1,10
  sum=0;
    DO 4 nbplayer=1,15
    4 sum = sum + a(10:15)
    WRITE (*,*) nbgame, sum
  3 CONTINUE

  WRITE (*,*) 'Each player average'

  CALL calculateavgpoints

  DO 5 nbgame=1,15
  sum=0
    DO 6 nbplayer=1,10
    6 sum=sum+a(10:15)
    sum=sum/10
    WRITE (*,*) nbgame, sum
  5 CONTINUE
  STOP
CLOSE (69)
END PROGRAM

and here is what i have for the module so far.
MODULE bballstatsmodule

IMPLICIT NONE
INTEGER, DIMENSION (15:10), ALLOCATABLE, INTENT (IN) :: game stats
INTEGER, DIMENSION (10), INTENT (INOUT) :: totalpointsarr
INTEGER, DIMENSION (15), INTENT (INOUT) ::avgpointsarr
INTEGER, INTENT (IN) :: numrows
INTEGER, INTENT (IN) ::numcols

SUBROUTINE totalpoints

END SUBROUTINE

SUBROUTINE avgpoints

END SUBROUTINE
END MODULE bballstatsmodule
gummibaer (Programmer)
23 Apr 12 13:11
And what is the problem where you got stuck ?

The best test to find the first set of errors is to compile it and see what errormessages you get.

Norbert
 

The optimist believes we live in the best of all possible worlds - the pessimist fears this might be true.

6berry (Programmer)
23 Apr 12 13:16
i have been working on it but im not able to figure it out. if you could just give me an idea of what i can change to or how to change it to work i woyuld appreciate it a lot
gummibaer (Programmer)
23 Apr 12 14:36
The clue to it all would be the errormessages that your compiler will hurl at you once you try to compile. I got 29 errormessages when I tried to compile your code and they are quite illuminating. To erase these is your work for I guess, there is a reason why you attend this course.

You should consider to have a look at a textbook or on your course's notes to understand the basic rules of what you are doing.

Norbert
 

The optimist believes we live in the best of all possible worlds - the pessimist fears this might be true.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close