Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a PERL script called tempConverter that takes one input argument for Fa

ID: 3704071 • Letter: 1

Question

1. Write a PERL script called tempConverter that takes one input argument for Fahrenheit-and processes the Fahrenheit to Celsius using the formula below to convert the temperature entered to Celsius:

Celsius: C = (F – 32) * (5 / 9)

-First, prompt the user for the city name and read the city

-Second, prompt the user for the temperature in Fahrenheit

-Process the temperature conversion using the formula given above

-Based on the new Celsius temperature, display a short message telling the user if it’s winter, summer or fall based.

-Use the IF, ELSE statements to check for the season as we did in previous lab activities.

Note: You may need to use the chomp () function in PERL to remove any trailing string or extra space in the input.

2. Write a PERL script/program based on the following requirements. The program should prompt the user for how many courses they plan to take next semester and ask the user to enter each of those courses before displaying all the information entered back on the screen.

3. Write a PERL script that defines/declares an array or a list of elements. The array should hold three-letter abbreviations for the first six months of the year and display the array/list.

Explanation / Answer

################# Program 1) #####################
#! /usr/bin/perl

print "Enter the temperature in Fahrenheit :: ";
my $fahr = <STDIN>;
chomp($fahr);
my $cel = ($fahr - 32) * (5 / 9);
print " <============== Fahrenheit to Celcius Conversion ==============> ";
print "Temperature in Fahrenheit ", $fahr, " Temperature in Celcius ". $cel." ";
print "<==============================================================> ";

##################### OUTPUT OF PROGRAM #################################
#Enter the temperature in Fahrenheit :: 1245
#
#<============== Fahrenheit to Celcius Conversion ==============>
#Temperature in Fahrenheit 1245 Temperature in Celcius 673.888888888889
#<==============================================================>
#########################################################################


################# Program 2) #####################
#! /usr/bin/perl

print "How many subjects you plan to take next semester :: ";
my $total_course = <STDIN>;
my @arr, $subject;
chomp($total_course);
for ($i = 0; $i < $total_course; $i++) {
  print "Enter the course name for subject ", $i + 1, " :: ";
  $subject = <STDIN>;
  chomp($subject);
  $arr[$i] = $subject;
}
print "<==============================================================> ";

print " <========================== Summary ===========================> ";
print "Total no. of subjects :: ", $total_course, " ";
print "Name of subjects opted for next semester are ";
for ($i = 0; $i < $total_course; $i++) {
   print $i + 1, ") ", $arr[$i], " ";
}
print "<==============================================================> ";

##################### OUTPUT OF PROGRAM #################################
#How many subjects you plan to take next semester :: 5
#Enter the course name for subject 1 :: Electrical
#Enter the course name for subject 2 :: Maths
#Enter the course name for subject 3 :: Networks
#Enter the course name for subject 4 :: DataManagement
#Enter the course name for subject 5 :: InformationSecruity
#<==============================================================>
#
#<========================== Summary ===========================>
#Total no. of subjects :: 5
#Name of subjects opted for next semester are
#1) Electrical
#2) Maths
#3) Networks
#4) DataManagement
#5) InformationSecruity
#<==============================================================>
#########################################################################


################# Program 3) #####################
#! /usr/bin/perl
A
my @arr = ("Jan", "Feb", "Mar", "Apr", "May", "Jun");
print "<== The first six month initial 3 letters are ==> ";
my $i = 1;
print "============================== ";
print " Month | Initial Letters ";
print "============================== ";
foreach my $temp (@arr) {
   print " $i | $temp ";
   $i++;
}

##################### OUTPUT OF PROGRAM #################################
#<== The first six month initial 3 letters are ==>
#==============================
# Month
| Initial Letters
#==============================
# 1
| Jan
# 2
| Feb
# 3
| Mar
# 4
| Apr
# 5
| May
# 6
| Jun
#########################################################################