Question

In: Computer Science

Implement a simple football league system that will record and display the league according to the...

Implement a simple football league system that will record and display the league according to the following specification: Each Team will have the following attributes: • Name • Games played • Games won • Games lost • Games drawn (this should be a calculated value) • Points (calculate using 3 points for a win and 1 for a draw)

Your program must include the following functionality:

  • The ability to enter a team’s results from the keyboard.
  • All records entered must be written to a text file.
  • The system must allow new records to be added to the end of the file.
  • An option to read the file and display the information on the screen should be given.
  • Your program should run all the above functions without shutting down.
  • You can include any additional functionality that you consider would make the program more useful or user friendly.

Solutions

Expert Solution

For this question,you did not mention in which language you want a code .so, I write a code in Python language :-

ch='y'
while(ch!='Q'):
    display=str(input("\nEnter 'N' for new record\n'D' for display information\n'Q' to Quit:"))
    if display=='N': # if user enter 'N' for add new record
            #now get attributes: Name , Games played ,Games won , Games lost
            name = str(input ("Enter a Team Name :"))     
            gameplayed= int (input("Enter a Total Game played :"))
            gamewin = int (input("Enter a Total Game Win:"))
            gamelost=int (input("Enter a Total Game lost:"))
            gamesdrawn=gameplayed-gamewin-gamelost         #calculate gamesdrawn
            points=3*gamewin+1*gamesdrawn                  #calculate points

            file1=open("game.txt", "a")           # open game.txt file here 'a' for add data to end of the file
            # now write all attributes into file
            file1.writelines(name+"\t\t\t")         
            file1.writelines(str(gameplayed)+"\t\t")
            file1.writelines(str(gamewin)+"\t\t")
            file1.writelines(str(gamelost)+"\t\t")
            file1.writelines(str(gamesdrawn)+"\t\t")
            file1.writelines(str(points)+"\n")
            file1.close() #close the file
    elif display=='Q':   #if user enter 'Q' then quit
            break
    elif display=='D': #if user enter 'D' then display information
            file1=open("game.txt", "r")   #open file for read
            Lines = file1.readlines() #get all lines from game.txt file
            print("name\t\t\t"+"gameplayed\t"+"gamewin\t\t"+"gamelost\t"+"gamesdrawn\t"+"points")
            for line in Lines:
    #We can iterate over the list and strip the newline '\n' character using strip() function      
                print(line.strip()) #print all record line by line,
            file1.close()   #close file
   

Screenshot of code, game.txt file and output :-


Related Solutions

.According to a recent random sample of 31 Canadian Football League players, the mean age was...
.According to a recent random sample of 31 Canadian Football League players, the mean age was approximately 27.71 years with a variance of 2.59. Lonnie Lobowsky of the Yukon Argonauts has an age with z-score equivalent to 2.21. Determine his age. A. 31 B. 37 C. 33 D. 35 E. 28
The National Football League (NFL) polls fans to develop a rating for each football game. Each...
The National Football League (NFL) polls fans to develop a rating for each football game. Each game is rated on a scale from 0 (forgettable) to 100 (memorable). The fan ratings for a random sample of 12 games follow. 57 61 85 73 71 73 20 58 80 79 84 73 a. Develop a point estimate of mean fan rating for the population of NFL games (to 2 decimals). b. Develop a point estimate of the standard deviation for the...
The National Football League (NFL) polls fans to develop a rating for each football game. Each...
The National Football League (NFL) polls fans to develop a rating for each football game. Each game is rated on a scale from 0 (forgettable) to 100 (memorable). The fan ratings for a random sample of 12 games follow. 57 62 87 73 72 72 20 56 79 78 83 73 b. Develop a point estimate of the standard deviation for the population of NFL games (to 4 decimals).
The National Football League (NFL) holds its annual draft of the nation's best college football players...
The National Football League (NFL) holds its annual draft of the nation's best college football players in April each year. Prior to the draft, various sporting news services project the players who will be drafted along with the order in which each will be selected in what are called mock drafts. Players who are considered to have superior potential as professional football players are selected earlier in the draft. Suppose the following table shows projections by one mock draft service...
The National Football League (NFL) holds its annual draft of the nation's best college football players...
The National Football League (NFL) holds its annual draft of the nation's best college football players in April each year. Prior to the draft, various sporting news services project the players who will be drafted along with the order in which each will be selected in what are called mock drafts. Players who are considered to have superior potential as professional football players are selected earlier in the draft. Suppose the following table shows projections by one mock draft service...
The National Football League (NFL) holds its annual draft of the nation's best college football players...
The National Football League (NFL) holds its annual draft of the nation's best college football players in April each year. Prior to the draft, various sporting news services project the players who will be drafted along with the order in which each will be selected in what are called mock drafts. Players who are considered to have superior potential as professional football players are selected earlier in the draft. Suppose the following table shows projections by one mock draft service...
The National Football League (NFL) holds its annual draft of the nation's best college football players...
The National Football League (NFL) holds its annual draft of the nation's best college football players in April each year. Prior to the draft, various sporting news services project the players who will be drafted along with the order in which each will be selected in what are called mock drafts. Players who are considered to have superior potential as professional football players are selected earlier in the draft. Suppose the following table shows projections by one mock draft service...
Write a C++ program to help the Administration of a football league to manipulate the list...
Write a C++ program to help the Administration of a football league to manipulate the list of players registered in different teams. There are 26 teams participating in the league, each is denoted by a letter in the range A to Z. Each team can have 11 players at most. The information of all teams' players are stored in a text file named 'players.dat'. Each line from the input file contains the details of one player; where the player's details...
The National Football League (NFL) records a variety of performance data for individuals and teams. To...
The National Football League (NFL) records a variety of performance data for individuals and teams. To investigate the importance of passing on the percentage of games won by a team, the following data show the conference (Conf), average number of passing yards per attempt (Yds/Att), the number of interceptions thrown per attempt (Int/Att), and the percentage of games won (Win%) for a random sample of 16 NFL teams for the 2011 season (NFL web site, February 12, 2012) Team Conference...
Suppose the weights of tight ends in a football league are normally distributed such that σ2=1,369....
Suppose the weights of tight ends in a football league are normally distributed such that σ2=1,369. A sample of 49 tight ends was randomly selected, and the weights are given below. Use Excel to calculate the 95% confidence interval for the mean weight of all tight ends in this league. Round your answers to two decimal places and use ascending order. Weight 300 294 155 270 218 242 150 364 298 167 297 299 221 266 261 301 269 267...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT