Professional Documents
Culture Documents
Homework#3
Homework#3
\n";
print "This is my homework #3.\n";
$|=1;
while (1){
print "Which work do you want to run? \n(1,2,3,4,5=homework1,2,3,4,5 lea
ve=0): ";
chomp($k=<STDIN>);
if ($k==0){
last; #0NX
}
print "\n============================= Homework ${k} ===================
===============\n";
if ($k==1){
print "This is the homework1.\n";
print "Please enter 3 numbers(A, B and C) for the quadratic equa
tions.\n\n";
my @Input = ("a","b","c");
for($i=0; $i<=$#Input; $i++){
print "The input number \'$Input[$i]\' is: ";
chomp($Input[$i]=<STDIN>);
}
#Input[0-2]Oa, b, c
$Denom = 2*$Input[0];
#(2a)
$Check = $Input[1]**2-4*$Input[0]*$Input[2];
#P_ (b^2-4ac)
elsif ($k==3){
print "This is the homework3.\n";
for($i=1;$i<601;$i+=4){
$sum2=$sum2+$i**3;
}
print "The sum is \"$sum2\".\n";
}
){
elsif($k==4){
print "This is the homework4.\n";
for($i=0;$i<=8000;$i++){
if ($i%2!=0 or $i%3!=0 or $i%5!=0 or $i%7!=0 or $i%11!=0
}
$sum3=$sum3+$i;
}
print "The sum is \"$sum3\".\n";
elsif($k==5){
print "This is the homework5.\n";
for ($i=1;$i<10;$i++){
for($j=1;$j<10;$j++){
$x=$i*$j;
print "$x ";
}
print "\n";
}
}
print "\nPress Enter to continue...";
chomp($o=<STDIN>);
system("cls");
}#end of while