ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 12 Weeks Ago, 5 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 08 May 2017 My Price 9.00

Write a function that will take the name of a file

Part 1 : 20 points

Write a function take a file name as a parameter. This function will open the given file for reading and then read each line of the input file and put each line into a list. If the user passes the name of a file that doesn’t exist you should catch the exception that is thrown by the open() function and return an empty list. If a valid file name is passed this function will return the list that is created.

Part 2 : 20 points

Write a function that will take a list as a parameter. This list will be the list from the previous function. This function will take each element of that list and calculate the Quarterback rating for each QB in the list. You will want to use the float() function instead of the int() function to convert strings to numbers. For each line you will create a tuple where the first element of the tuple is the Quarterback’s name and the second element is the quarterback’s Passer rating. You will then place that tuple into a list. This function will return that list. The formula for Passer Rating is as follows:

 

Part 3 : 20 Points

Write a function that will accept a list as a parameter. This list will be the list from the previous function. This function will use the selection sort algorithm that we used earlier in the semester to sort

the list according to each quarterback’s QB rating. This list will be sorted so that the highest QB rating is at the top instead of the lowest QB rating. Remember, you are sorting the tuples, not JUST the qb ratings. You should end up with a list of tuples that is sorted by QB rating and each tuple will have the name and rating for a quarterback. Remember, since lists are pass by reference you will not need to return the list from this function. Do NOT use built in sorting functions

Part 4 : 20 points

Write a function that will take the name of a file and a list. This list will be the sorted list from the list from the previous function. This function will open a file for writing with the name of the file that was passed. It will then write the contents of each tuple to that file. Each line should first write the QB rating followed by the name of the quarterback who had that rating. This is should be the reverse of the order that these elements are stored in each tuple. Do not print the parentheses of the tuple to the file.

Part 5 : 20 points

Write a main function that will display a menu with 6 options: Select input file, Calculate ratings, Sort ratings, Output ratings to a file, Output ratings to console, and exit.

If select input file is chosen you should prompt the user for a file name, call the function from part 1 and store the returned value in a variable.

If calculate ratings is selected and QB statistics have already been read you should call the function from part 2 with the list returned from part 1 and store the returned value in a variable. If calculate ratings is selected and QB statistics have not been read you should tell the user that no statistics have been read.

If sort ratings is selected and QB ratings have been calculated you should call the function from part 3 with the list returned from part 2. If sort ratings is selected and QB ratings have not been calculated then you should tell the user that no ratings have been calculated.

If output ratings to file is selected and the ratings list has been calculated and sorted you should prompt the user for a file name and call the function from part 4 with the file name they input and the sorted list as arguments. If output ratings to file is selected and the ratings list has not been calculated or sorted you should inform the user that the list either has not been calculated or has not been sorted.

Selecting Output ratings to console will operate similarly to Output ratings to file except you will not have to prompt the user for a file name and you will print to the console instead of a file. You may write a function for this if you would like but you do not have to.

After each selection that the user makes your program should execute the appropriate actions, reprint the menu and prompt the user for another selection until they select exit.

If the user enters a selection that is not a valid menu selection you should ask the user to make another selection and redisplay the menu

 

Project 1For this project you will be provided with a file to read. This file will contain the names of 20Quarterbacks. Next to each name will be 5 stats separated by spaces: Completions, Attempts, Yards,Touchdowns, Interceptions in that order. This file will be the input file for your program. All of thefollowing functions should be put into one file.Part 1 : 20 pointsWrite a function take a file name as a parameter. This function will open the given file forreading and then read each line of the input file and put each line into a list. If the user passes the nameof a file that doesn’t exist you should catch the exception that is thrown by the open() function andreturn an empty list. If a valid file name is passed this function will return the list that is created.Part 2 : 20 pointsWrite a function that will take a list as a parameter. This list will be the list from the previousfunction. This function will take each element of that list and calculate the Quarterback rating for eachQB in the list. You \ you will create a tuple where the first element of the tuple is the Quarterback’sname and the second element is the quarterback’s Passer rating. You will then place that tuple into alist. This function will return that list. The formula for Passer Rating is as follows:Part 3 : 20 PointsWrite a function that will accept a list as a parameter. This list will be the list from the previousfunction. This function will use the selection sort algorithm that we used earlier in the semester to sort

Eric Dungey 224 346 2631 15 6Drew Lock 137 257 1995 20 1Austin Allen 155 249 2048 18 7Tyler Rogers 155 279 1994 11 10Kenny Hill 180 287 2290 13 9Patrick Mahomes II 246 260 3313 26 6Brent Stockstill 202 317 2371 22 5Luke Falk 253 348 2511 19 5Mitch Trubisky 203 285 2378 18 2Phillip Walker 132 231 1791 11 10Quinton Flowers 136 229 1941 17 5Deshaun Watson 164 258 1950 20 8Aaron Rodgers 209 316 2566 24 8Jerod Evans 141 226 2017 21 2Ryan Higgins 190 279 2622 24 3Baker Mayfield 152 213 2348 23 5Cooper Rush 167 274 2289 19 8Chad Kelly 153 246 2067 15 7Brett Rypien 137 219 2064 15 5Chason Virgil 165 321 2013 13 10

Attachments:

Answers

(11)
Status NEW Posted 08 May 2017 04:05 AM My Price 9.00

-----------

Not Rated(0)