1. Write a PERL PROGRAM that reads in, displays, and manipulates an array of employee records.
An employee record has the following structure:
Name : NameType
Age : Integer
Hourly Rate : Real
First : String
Middle : String
Last : String
The raw data for the employee record is stored in space delimited format in the file employee.txt:
robert francis dugan 40 10.00
rebecca mae dugan 32 15.00
benjamin robert dugan 0 5.00
cricket dory dugan 22 8.00
micheal gerald dugan 39 18.00
carrie marie dugan 40 12.00
timothy joseph dugan 37 15.00
stacy jane dugan 37 19.00
patricia agnes dugan 65 20.00
anne marie dugan 93 12.00
Your program should do the following:
a) Read in the contents of employee.txt into an appropriate set of data structures. You can only read the content of the employee.txt file ONCE at the beginning of the program.
b) Present the following menu of choices:
Employee Management System
1) List employees, age, and hourly rate
2) Display average age
3) Display average hourly rate
4) Display sum of weekly salaries
You should write subroutines to support each of the options on the user menu. The menu subroutines should process the data structure(s) that contain the employee data. Menu options 1-3 and 5 are self explanatory. Menu option 4 should compute the weekly salary for each employee, then sum up the salaries for a single answer.
Place your solution for 1 in a single file called “hw4.f”. Attach a hard copy of your code and a screen snapshot of the execution results to the homework assignment you hand in class.
Q2. Later versions of perl moved beyond the basic types of scalar, array, and hash and introduced a reference type.
Write a Perl subroutine, referenceTypeExample, to demonstrate your understanding of Perl’s reference type:
Create an integer variable “theInt” which is set to 42.
Create an alias for the theInt
Using the alias, increase the value of the integer variable by one
Print out the value of theInt (it should be 43)
Print out the value of the alias
Print out the value of theInt using the the alias
Q3 Support for a reference type means support for dynamic memory allocation. Write a Perl subroutine, dynamicArrayExample, that:
Creates and destroys an dynamic array of 100000 integers, all initialized to 42 500 times.
C++ used “new” and “delete” to allocate/deallocate dynamic memory. How does Perl deallocate dynamic memory?
It’s one thing to TALK about how Perl handles dynamic memory... it’s another thing entirely to SEE how Perl handles dynamic memory. What happens to the size of your Perl program as you make repeated calls to dynamicArray? To answer this question, you may want to use the Windows XP Task Manager to observe the memory consumed by your perl program.
Recently Asked Questions
- George, a 68 year old man, decided one Sunday afternoon to trim his hedge with the chain saw that he had bought from Bunnings with his birthday gift voucher.
- Please refer to the attachment to answer this question. This question was created from 65ffce915e2554fa348ed058c4626c52_78fbb1ebe5fa1db21045dea727ac3609.
- Hello, I'm unsure how to solve these equations. Please provide details.