Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fortran 95 Programming help

Status
Not open for further replies.

6berry

Programmer
Apr 23, 2012
3
US
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!
 
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.
 
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
 
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.
 
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
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top