Tech Support Guy banner
Status
Not open for further replies.
1 - 1 of 1 Posts

· Registered
Joined
·
203 Posts
Discussion Starter · #1 ·
I have a Perl assignment that is driving me nuts. Here is what I don't understand.

1)How to get the ages to work like the names do.
2)How to get the names and ages to be displayed together.
3)How to show how many years till 25 that they are.

Below is the assignment and the coding.

Here is my assignment:

--Format an HTML page
--Declare an array of 10 names
--Add 3 new names to the name array
--Declare an array of 10 ages for the original 10 names
--Uses a control structure to:
--Print each name and age
--Print each name and the age the person will be in 25 years.
--Declare 2 numbers $a=2523 and $b=11 and perform the operations listed below. You may assign these values to new scalar variables:
--concatenate $a and $b to create $c -- print the value of $c
--repeat $c two times and print its value
--square $a and print the result
--divide $c by $a
--Determine the modulus of $c divided by $b
--Design and develop another feature for the program:
--Be sure to use comments to describe the feature.

Here is my coding thus far:

#!/usr/bin/perl
#Assignment4.pl Part B
print "Content-type: text/html\r\n\r\n";
print "Assignment#4";
print "
Assignment 4​

";
my @names;
$names[0]="Miguel ";
$names[1]="Roberto ";
$names[2]="Julio ";
$names[3]="Jorge ";
$names[4]="Mateo ";
$names[5]="Juan ";
$names[6]="Guillermo ";
$names[7]="Diego ";
$names[8]="Pablo ";
$names[9]="Antonio ";
my @ages;
$ages[0]="9";
$ages[1}="10";
$ages[2]="11";
$ages[3]="12";
$ages[4]="13";
$ages[5]="14";
$ages[6]="15";
$ages[7]="16";
$ages[8]="17";
$ages[9]="18";
foreach $names (@names) { print $names;};
foreach $ages (@ages) { print $ages;};
print 'Now, enter three more names:';
$names[10]="
Enrique
";
$names[11]="Carlos
";
$names[12]="Francisco
";
for(my $i=10;$i<13;$i++)
print $names[$i];
}
print "
This Totals 13 Names";
print"
";
print "

Please declare 2 numbers \$a=2523 and \$b=11.
";
$a=2523;
$b=11;
$c=$a.$b;
print "
The number is called \$c and its value is: ";
print $c;
print "
The total from repeating \$c two times is: ";
$c=$cx2;
print "

The value of \$a squared is: ";
print $a **2;
print "

The answer when you divide \$c by \$a is: ";
print $c/$a;
print "

The modulus of \$c divided by \$b is: ";
print $c%$b;
print "

Design and develop another feature for the program.
";
print "
When you take \$a and subtract \$b, you get a difference of ";
#This will simply subtract $b from $a;
print $a-$b;
print ".
";
print "";
exit;
 
1 - 1 of 1 Posts
Status
Not open for further replies.
Top