Question: write a Perl script called exam.pl to compute the final grade for a given student. Your script will be run with the command below: $

write a Perl script called exam.pl to compute the final grade for a given student. Your script will be run with the command below:

$ perl exam.pl

The table below summarizes the grading components:

Total Max

Quiz

10

Class Activities

135

Homework

150

Labs

155

Discussion

105

Exams

180

1. Set the total max of each grade component as constant

2. Write a function called sum that take an array of values, compute and return their sum

3. Write a function called percent that takes 2 values, compute and return the percentage of the first value relative to the second. For example, if 5 and 20 are passed to the function, it would return 25 (i.e. 5*100/20).

4. Write a function called grade that takes a percentage (number) and return the letter grade, with respect to the table below:

Percentage

Letter Grade

Percentage

Letter Grade

>= 95.0 <= 100.0

A+

>= 80.0 < 82.5

B-

>= 90.0 < 95.0

A

>= 77.5 < 80.0

C+

>= 87.5 < 90.0

A-

>= 70.0 < 77.5

C

>= 85.0 < 87.5

B+

>= 60.0 < 70.0

D

>= 82.5 < 85.0

B

< 60

F

5. Initialize a hash of scores to 0. The keys for the hash are the grading components. So the initial value for each component (i.e. quiz, hwk, etc.) in the hash would be 0.

6. For each component (use the foreach construct)

a. Prompt the user for a component score;

b. Store into the appropriate hash.

For example:

Enter the Quiz score: 9

Enter the Activities score: 125

7. Call the function sum passing the hash values as argument, store the return value in variable sum

8. Call the function percent passing the values sum and sum of Total Max as arguments. Store the return value in finalScore

9. Call the function grade passing finalScore as argument. Store the return value in variable finalGrade

10. Display the final Score and the final grade of the student.

(Partial) Roster file

"1209480997","0997-464","Anthony","Alvarado","3","Standard","Ira A Fulton Engineering - Information Technology","Senior","aalvar33","Non-Resident",

"1201390350","0350-574","Gibran","Alvarez","3","Standard","Ira A Fulton Engineering - Information Technology","Junior","galvare2","Resident",

"1000746988","6988-522","Glen","Angus","3","Standard","Ira A Fulton Engineering - Information Technology","Junior","gangus","Non-Resident",

"1207146326","6326-608","Cole","Ashby","3","Standard","Ira A Fulton Engineering - Information Technology","Senior","cashby","Non-Resident",

"1000548822","8822-019","Allan","Bailey","3","Standard","Ira A Fulton Engineering - Information Technology","Senior","asu41981","Resident",

"1208428789","8789-773","Rudy","Barron","3","Standard","Ira A Fulton Engineering - Information Technology","Junior","rrbarron","Non-Resident",

"1208427112","7112-644","Jeffrey","Box","3","Standard","Ira A Fulton Engineering - Information Technology","Post-Bacc Undergraduate","jabox1","Non-Resident",

"1206996878","6878-146","Nicholas","Burden","3","Standard","Ira A Fulton Engineering - Information Technology","Senior","nbburden","Non-Resident",

"1200663364","3364-155","Kurtis","Camiliere","3","Standard","Ira A Fulton Engineering - Information Technology","Senior","kcamilie","Resident",

"1000830925","0925-792","Michael","Camp","3","Standard","Ira A Fulton Engineering - Information Technology","Senior","mcamp1","Resident",

"1000727027","7027-763","Robert","Carleton","3","Standard","Ira A Fulton Engineering - Information Technology","Junior","rcarleto","Resident",

"1001460822","0822-945","Dustin","Cartwright","3","Standard","Ira A Fulton Engineering - Tech Entrepreneurship & Mgmt","Senior","dbcartwr","Resident",

"1201860560","0560-486","John","Cook","3","Standard","Ira A Fulton Engineering - Information Technology","Senior","jrcook7","Resident",

"1207331615","1615-810","Thomas","Debiasio","3","Standard","Ira A Fulton Engineering - Software Engineering","Post-Bacc Undergraduate","tdebiasi","Non-Resident",

"1208487705","7705-285","Jason","Dixon","3","Standard","Ira A Fulton Engineering - Software Engineering","Junior","jadixon5","Non-Resident",

"1207627963","7963-539","Jose","Fernandez","3","Standard","Ira A Fulton Engineering - Information Technology","Post-Bacc Undergraduate","jlferna4","Non-Resident"

(Partial) classroster

1209480997,0997-464,Anthony,Alvarado,3,Standard,Ira A Fulton Engineering - Information Technology,Senior,aalvar33,Non-Resident,

1201390350,0350-574,Gibran,Alvarez,3,Standard,Ira A Fulton Engineering - Information Technology,Junior,galvare2,Resident,

1000746988,6988-522,Glen,Angus,3,Standard,Ira A Fulton Engineering - Information Technology,Junior,gangus,Non-Resident,

1207146326,6326-608,Cole,Ashby,3,Standard,Ira A Fulton Engineering - Information Technology,Senior,cashby,Non-Resident,

1000548822,8822-019,Allan,Bailey,3,Standard,Ira A Fulton Engineering - Information Technology,Senior,asu41981,Resident,

1208428789,8789-773,Rudy,Barron,3,Standard,Ira A Fulton Engineering - Information Technology,Junior,rrbarron,Non-Resident,

1208427112,7112-644,Jeffrey,Box,3,Standard,Ira A Fulton Engineering - Information Technology,Post-Bacc Undergraduate,jabox1,Non-Resident,

1206996878,6878-146,Nicholas,Burden,3,Standard,Ira A Fulton Engineering - Information Technology,Senior,nbburden,Non-Resident,

1200663364,3364-155,Kurtis,Camiliere,3,Standard,Ira A Fulton Engineering - Information Technology,Senior,kcamilie,Resident,

1000830925,0925-792,Michael,Camp,3,Standard,Ira A Fulton Engineering - Information Technology,Senior,mcamp1,Resident,

1000727027,7027-763,Robert,Carleton,3,Standard,Ira A Fulton Engineering - Information Technology,Junior,rcarleto,Resident,

1001460822,0822-945,Dustin,Cartwright,3,Standard,Ira A Fulton Engineering - Tech Entrepreneurship & Mgmt,Senior,dbcartwr,Resident,

1201860560,0560-486,John,Cook,3,Standard,Ira A Fulton Engineering - Information Technology,Senior,jrcook7,Resident,

1207331615,1615-810,Thomas,Debiasio,3,Standard,Ira A Fulton Engineering - Software Engineering,Post-Bacc Undergraduate,tdebiasi,Non-Resident,

1208487705,7705-285,Jason,Dixon,3,Standard,Ira A Fulton Engineering - Software Engineering,Junior,jadixon5,Non-Resident,

1207627963,7963-539,Jose,Fernandez,3,Standard,Ira A Fulton Engineering - Information Technology,Post-Bacc Undergraduate,jlferna4,Non-Resident,

1207103803,3803-346,Hunter,Hale,3,Standard,Ira A Fulton Engineering - Information Technology,Junior,hehale,Non-Resident,

1207033252,3252-936,Thane,Heisey,3,Standard,Ira A Fulton Engineering - Information Technology,Junior,theisey,Non-Resident,

1000527662,7662-261,Jeremy,Hoyle,3,Standard,Ira A Fulton Engineering - Information Technology,Junior,jhoyle,Resident,

1201654029,4029-669,Parker,Jardine,3,Standard,Ira A Fulton Engineering - Information Technology,Post-Bacc Undergraduate,pjardine,Resident,

1000745321,5321-390,Joshua,Johnson,3,Standard,Ira A Fulton Engineering - Information Technology,Junior,jrjohnso,Resident,

1207997618,7618-802,Chinmingnon,Kone,3,Standard,Ira A Fulton Engineering - Information

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!