Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
- The problem statement, all variables and given/known data:
Here is the problem:
Lesson 13 OBJ1: OST Class online.
Write a script called obj13-1.pl and a library called obj13-lib.pl.
1- The library should contain a function that takes in an array of numbers (of arbitrary size).
2- The function will then (calculate the average of the numbers), (the total of all of the numbers added together), and a new array of numbers which is comprised of the (other numbers divided by 2).
It will then return a new list with all of that information.
The script file, obj13-1.pl should get a list of numbers from the user (either via STDIN or a list of arguments) and call the library function.
-
Relevant commands, code, scripts, algorithms:
-
The attempts at a solution (include all code and scripts):
My attempt at this, remember I'm a newbie to unix/linux:Obj13-1.pl
#!�usr/bin/perl
require �obj13-lib.pl�;
@userarray = <STDIN>;
$sum = sumIt(@userarray);
$ave = $sum/(@userarray);
print�Total: $sum\n�;
print�Average: $ave\n�;
foreach((@userarray)/2){ THIS PART IS WRONG yes I need a foreach loop to draw out the input numbers, but (@userarray)/2) isn't working.
print�Divided by 2: @userarray\n�;
}
#_END_
Obj13-lib.pl
Sub sumIt{
@functionarray = @_;
foreach $line(@functionarray){
$functionsum += $line;
}
return $funtionsum;
}
1;
- Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
OST OReilly School of Technology, Online course, USA, Kelly Hoover instructor. Course is Unix/Linux administration.
Tried to post this and got this msg: So I'm taking the link to my class out.
- "You are only allowed to post URLs once you have at least 5 posts"
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).