I was hoping to transfer to another department, where I could do more than what I’m doing now (IT Specialist on the midshift), an opportunity came up in the programming department on the dayshift, something I would like to do, but my supervisor throws me a curve by giving me 4 problems to do, I didn’t think there be a problem, but then he told me i had to do it another program other than UNIX!!! I’ve taken C++ and Perl classes in college, but thats the extent of it. I never worked with it outside of class, the problems look vaguely familiar, but who keeps all thier old college textbooks, especially Perl!!!
I need help, I would rather back out of this, but my Lead IT helped to get me this interview. Also is it fair or common for a supervisor to do this? I learn much faster when I’m thrown into the environment and catch on pretty quickly…but to be given an assignment???
You think its his way of saying, “No chance” bud?! And just gave me the problems as a way of discouraging me…I’m stressing.
Problem 1:
The programmers need a tool that can count the number of lines in
text file (assume that there is no ‘wc’ command). The tool must named
‘linecount’ and it takes one argument on the command line. That argument
is the text file for which a count of lines is to be calculated. After the
command is executed, the message “>>>There were ### lines in the file:
<filename>”; where ### is the number of lines in the file, and <filename> is
the name of the file passed as the command line argument.
Problem 2:
Using the newly available comment ‘linecount’ from problem 1, build a tool
named ‘countall’ that will automatically display the number of lines in
each file in a directory. For example, if a directory contained the files:
text1, text2, text3, text4, then the command invocation and output might
look
something like this (if running on system asd1us) :
asd1us$ countall
There were 25 lines in the file: text1
There were 54 lines in the file: text2
There were 345 lines in the file: text3
There were 5 lines in the file: text4
asd1us$
Problem 3:
Assume there is no calculator program on the unix/linux systems at FNMOC.
Build a simple calculator that is named ‘mycalc’ that has the following
command line:
mycalc [add | sub | mult | div] [number] [number]
Example: mycalc sub 4 3
Result: >>> 4 – 3 = 1
Example: mycalc div 54 9
Result: >>> 54 / 9 = 6
The tool must check that all arguments are present, that each is valid, and
in
the case of ‘div’, it must check for the last argument to assure it is NOT
zero. If it is zero, it should print the message: >>> Division by zero is
not
permitted!
Problem 4:
FNMOC developers need a tool to calculate the factorial of any number. Find
an algorithm for calculating factorials, and make a tool called
‘myfactorial’ that takes a single numeric argument and produces the
factorial for that number.
Example command line: myfactorial 5
Exampple result: >>> The factorial of 5 is 120