Question
Part I of this question uses UNIX shell commands. Parts II and III use awk and perl scripting, respectively. Part I: Consider the file roster
Part I of this question uses UNIX shell commands. Parts II and III use awk and perl scripting, respectively.
Part I:
Consider the file roster provided at the end of this exam. Assume it is currently in your home directory.
The fields are: Student ID, Posting ID, First Name, Last Name, Units, Grade Basis, Program and Plan, Academic Level, ASURITE, and Residency.
Provide the command(s) to perform the tasks below.
1. First you move the file to your ~/IFT383/Exams directory, change your working directory to ~/IFT383/Exams, convert the file to UNIX, and then open it in vi for editing.
2. Next, you get rid of all the double quotes inside the file, save as roster1 and exit vi
3. You also explore using the tr command to get rid of the double quotes in the file roster and save it as roster2
4. Then you perform a byte-by-byte comparison of the two files (roster1 and roster2) to display the list of mismatches.
5. You then rename roster1 as classroster
6. You use cat command to create a file called header whose contents are the field names written exactly as mentioned in the introduction above.
7. Open both header and classroster files in vi, then copy the contents of header into classroster, as the first line.
8. Now you use appropriate simple filters (i.e. filters covered in Unit3, such as cut, paste, tr, head, etc.) to format the file classroster obtained from step 7) so it looks like below (note the space characters before and after the colon). Save the formatted file as iclassroster
Last Name:First Name:Student ID:Program and Plan:Academic Level:ASURITE
9. You want to know how many students in the class are from IT program.
10. You want to know how many senior students from IT program are in the class.
Part II:
Consider the file classroster shown in the last part of this question. Now we need to write a awk script, exam.awk, to perform the tasks in Part I above.
The breakdown of the problem is described below. Write your awk script according to those steps.
You will run the script from the command prompt with the following command:
$ awk f exam.awk classroster
A. Pre-processing tasks
1. Insert the header line below in the output:
Student ID, Posting ID, First Name, Last Name, Units, Grade Basis, Program and Plan, Academic Level, ASURITE, Residency, Email
2. Set the field separator to the appropriate character
B. For each record,
1. Create a formatted file, called iclassroster, that looks as shown below:
Last Name : First Name : Student ID : Program and Plan : Academic Level : ASURITE
2. Use if elseif else construct to track the number of
Students in the class from IT program
Freshman
Junior
Sophomore
Senior
Post-Bacc Undergraduate
Students from neither of the above listed academic levels
3. Create a new field called Email that is made of ASURITE@asu.edu
4. Print the new record, which includes the new field
C. Finally
1. Display the total number of records
2. Display the number of students from IT Program
3. Display the number of Freshman
4. Display the number of Junior
5. Display the number of Sophomore
6. Display the number of Senior
7. Display the number of Post-Bacc Undergraduate
8. Display the number of Students from other academic levels
Part III:
In this part, you will 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:
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:
1. 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.
2. 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
3. Call the function sum passing the hash values as argument, store the return value in variable dum
4. Call the function percent passing the values dum and sum of Total Max as arguments. Store the return value in finalScore
5. Call the function grade passing finalScore as argument. Store the return value in variable finalGrade
6. Display the final Score and the final grade of the student.
Here are the partial contents of the "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"
Here are the partial contents of the "classroster" 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,
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 Technology,Junior,cdkone,Non-Resident
Please provide detailed and complete answers to each part of the question. For part I, use UNIX shell commands only!!! For Parts II and III, use awk and perl scripting ONLY, RESPECTIVELY. Do NOT answer in Java/programming language code.
Daniel Travis M FT383 lab Fir Spring 2017 Insert vraw Lesign Layout Reterences Mailings Review view Tell me what you want to do File Home AaB Aria AaBb AaBb AaBbc AaBbcel AaB,C Paste B mphasis 1Heading 1 Heading 2 1 Heading 3 1 Normal Strong subtito 1 Titte No Spac... Subtle Em Intonso E., Format Painte Total Max Quiz 10 135 Class Activities 150 Homework 155 Labs 105 Discussion 180 Exams Page of a O Type here to search Share Find Replace 2242 AM 1/27/2017 Daniel Travis M FT383 lab Fir Spring 2017 Insert vraw Lesign Layout Reterences Mailings Review view Tell me what you want to do File Home AaB Aria AaBb AaBb AaBbc AaBbcel AaB,C Paste B mphasis 1Heading 1 Heading 2 1 Heading 3 1 Normal Strong subtito 1 Titte No Spac... Subtle Em Intonso E., Format Painte Total Max Quiz 10 135 Class Activities 150 Homework 155 Labs 105 Discussion 180 Exams Page of a O Type here to search Share Find Replace 2242 AM 1/27/2017Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started