VB icon

Math Calculator in Perl CGI

Email
Submitted on: 8/5/2016 12:40:33 PM
By: Jake R. Pomperada  
Level: Beginner
User Rating: Unrated
Compatibility: 5.0 (all versions), Active Perl specific
Views: 2841
author picture
 
     A simple math calculator that I wrote using Perl CGI that will accept two numbers from the user and then it will compute for the sum, difference, product and quotient of the number given by our user. Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
=**************************************
= Name: Math Calculator in Perl CGI
= Description:A simple math calculator that I wrote using Perl CGI that will accept two numbers from the user and then it will compute for the sum, difference, product and quotient of the number given by our user.
Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
= By: Jake R. Pomperada
=**************************************

<!-- input.php -->
<html>
<head>
<title>Math Calculator in Perl</title>
</head>
<style>
 body {
font-family: arial;
font-size: 18px;
font-weight: bold;
 };
</style>
<body>
<h3> Math Calculator in Perl </h3>
<table border="0">
 <tr>
<td align="center"></td>
 </tr>
 <tr>
<td>
 <table>
<form method="post" action="\cgi-bin\form.pl">
<tr>
 <td>First Number</td>
 <td><input type="text" name="val1" size="5"></td>
</tr>
<tr>
 <td>Second Number</td>
 <td><input type="text" name="val2" size="5"></td>
</tr>
<tr></td>
 <tr>
 <td></td>
<tr></td>
<tr></td>
 <td align="right"><input type="submit" name="submit" value="Compute"></td>
</tr>
</table>
 </td>
</tr>
</table>
</body>
</html>
form.pl
#!"C:\xampp\perl\bin\perl.exe"
use CGI;
use Math::Round;
CGI::ReadParse();
$val1 = $in{'val1'};
chomp($val1);
$val2 = $in{'val2'};
chomp($val2);
$add=$val1+$val2;
$subract=$val1-$val2;
$product=$val1*$val2;
$quotient=$val1/$val2;
my $rounded = sprintf("%0.2f", $quotient);
CGI::PrintHeader();
print "content-type:text/html\n\n";
print "<HTML>";
print "<font size='5'>";
print "<br>";
print "<head><title>Math Calculator in Perl</title></head>";
print "<body style='font-family:arial;'>";
print "<h4> Math Calculator in Perl </h4>";
print "Created By: Mr. Jake R. Pomperada, MAED-IT<br>";
print "<br>";
print "The sum of $val1 and $val2 is $add.<br>";
print "The difference between $val1 and $val2 is $subract.<br>";
print "The product of $val1 and $val2 is $product.<br>";
print "The quotient of $val1 and $val2 is $rounded";
print "</body>\n";
print "</html>\n";


Other 22 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.