Question & Answer: Can someone explain each line?…..

Can someone explain each line?

#! usr/bin/perl
print “Enter the Quiz score: “;
$quiz = <>;
print “Enter the Activity score: “;
$classactivities = <>;
print “Enter the homework score: “;
$homework = <>;
print “Enter the labs score: “;
$labs = <>;
print “Enter the discussion score: “;
$discussion = <>;
print “Enter the exams score: “;
$exams = <>;

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: Can someone explain each line?…..
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

my %hash = ($quiz,
$classactivities,
$homework,
$labs,
$discussion,
$exams );

my @scores = (65,67,78,90); #array of number
my $returned_values;
$returned_values = sum(@scores); #calling sum function
print “sum value = $returned_values n”;
$returned_values = percent(5,20); #pass any value here
print “percent value = $returned_values n”;
$returned_values = grade(72);
print “grade $returned_valuesn”;

sub sum{
my @score_list = @_; #parameters are stored in @_
my $result = 0;
for (@score_list) {
$result = $result + $_; #computing sum
}
return $result;
}

sub percent{
my($first,$second) = @_;
my $result = ($first*100)/$second;
return $result;
}

sub grade{
my $percentage = $_[0];
return “unknown grade” if($percentage > 100); #passed value is greated then 100
return “A+” if($percentage >= 95.0 and $percentage <= 100.0);
return “A” if($percentage >= 90.0 and $percentage <= 95.0);
return “A-” if($percentage >= 87.5 and $percentage <= 90.0);
return “B+” if($percentage >= 85.0 and $percentage <= 87.5);
return “B” if($percentage >= 82.5 and $percentage <= 85.0);
return “B-” if($percentage >= 80.0 and $percentage <= 82.5);
return “C+” if($percentage >= 77.5 and $percentage <= 80.0);
return “C” if($percentage >= 70.0 and $percentage <= 77.5);
return “D” if($percentage >= 60.0 and $percentage <= 70.0);
return “F” if($percentage <= 60.0);
}

Expert Answer

 

#! usr/bin/perl
print “Enter the Quiz score: “;
##Ask user to enter the score
$quiz = <>;
print “Enter the Activity score: “;
##Ask user to enter the Activity score
$classactivities = <>;
print “Enter the homework score: “;
##Ask user to enter the homework score
$homework = <>;
print “Enter the labs score: “;
##Ask user to enter the labs score:
$labs = <>;
print “Enter the discussion score: “;
##Ask user to enter the discussion score:
$discussion = <>;
print “Enter the exams score: “;
##Ask user to enter the exams score:
$exams = <>;
my %hash = ($quiz,
$classactivities,
$homework,
$labs,
$discussion,
$exams );

my @scores = (65,67,78,90); #array of number
my $returned_values; #variable declaration
$returned_values = sum(@scores); #calling sum function to calculate the sum
print “sum value = $returned_values n”;#print statement
$returned_values = percent(5,20); #pass any value here to get the percent
print “percent value = $returned_values n”;
$returned_values = grade(72);#function call to grade to get the grade
print “grade $returned_valuesn”;

sub sum{
my @score_list = @_; #parameters are stored in @_
my $result = 0;
for (@score_list) {
$result = $result + $_; #computing sum
}
return $result; ##return the sum
}
sub percent{
my($first,$second) = @_;
my $result = ($first*100)/$second; #calculate percent
return $result;
}
sub grade{
my $percentage = $_[0];
return “unknown grade” if($percentage > 100); #passed value is greated then 100
return “A+” if($percentage >= 95.0 and $percentage <= 100.0); ##if percent is between 95 to 100
return “A” if($percentage >= 90.0 and $percentage <= 95.0);##if percent is between 90 to 95
return “A-” if($percentage >= 87.5 and $percentage <= 90.0);##if percent is between 87.5 to 90
return “B+” if($percentage >= 85.0 and $percentage <= 87.5);##if percent is between 85 to 87.5
return “B” if($percentage >= 82.5 and $percentage <= 85.0);##if percent is between 82.5 to 85
r
eturn “B-” if($percentage >= 80.0 and $percentage <= 82.5);##if percent is between 80 to 82.5
return “C+” if($percentage >= 77.5 and $percentage <= 80.0);##if percent is between 77.5 to 82.5
return “C” if($percentage >= 70.0 and $percentage <= 77.5);##if percent is between 70 to 77.5
return “D” if($percentage >= 60.0 and $percentage <= 70.0);##if percent is between 60 to 70
return “F” if($percentage <= 60.0);
}

=================
Comments explain each line

See Output to understand more and relate

Grand Paper Writers
Order NOW For A 10% Discount!
Pages (550 words)
Approximate price: -

Our Advantages

Plagiarism Free Papers

All papers are written by the best professional writers to ensure 100% originality. We always provide plagiarism reports whenever we deliver completed papers.

Free Revisions

All papers by Grand Paper Writers are completed and submitted on time. This timely delivery of papers gives you time to go through the paper before the official deadline.

Title-page

As an additional service, we will provide a title page that precedes the contents of your paper. Here, you will provide your personal details.

Bibliography

We also ensure that we provide an extra page for the references or bibliographies following referencing rules.

Originality & Security

At Grandpaperwriters.com, we guarantee students for the provision of security and original work. All your personal information is handled with confidentiality and is not shared with third parties. Additionally, we ensure that we provide original content with accompanying plagiarism reports to show originality.

24/7 Customer Support

Our customer support team is always available 24/7 to provide instant responses to any queries raised by students.

Try it now!

Calculate the price of your order

We'll send you the first draft for approval by at
Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

Grandpaperwriters.com has the best professional essay writers for quality services.

Pricing

Flexible Pricing

Here, a Grandpaperwriters.com, we do not compromise on the time of our clients. We always deliver all completed papers on or before the deadlines.

Communication

Admission Help & Client-Writer Contact

Grandpaperwriters.com provides an interactive portal where students can communicate directly to their writers.

Deadlines

Paper Submission

Here, a Grandpaperwriters.com, we do not compromise on the time of our clients. We always deliver all completed papers on or before the deadlines.

Reviews

Customer Feedback

Grandpaperwriters.com appreciates feedback from our clients to help us improve the delivery of essay writing services. As such, we are constantly changing our policies to ensure maximum customer and writer satisfaction.