Saturday, August 6, 2016

Year Level Checker in Pascal

A simple program that I wrote in Pascal to check if the given year level of the student belongs to freshmen, sophomore, junior, seniors or invalid year level. The code is very simple and easy to understand I am using Turbo Pascal 5.0 for DOS in this sample program.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.







Sample Program Output


Program Listing

Program Year_Level;
Uses Crt;

Var year_level_students  : Integer;

Begin
  Clrscr;
  Write('Year Level Checker in Pascal');
  writeln;
  writeln;
  Write('Give the year level of the student :');
  readln(year_level_students);

  if (year_level_students = 1) then
    Begin
    Writeln;
    Writeln('You are belong to Freshmen.');
    End
  else if (year_level_students = 2) then
    Begin
    Writeln;
    Writeln('You are belong to Sophomore.');
    End
  else if (year_level_students = 3) then
    Begin
    Writeln;
    Writeln('You are belong to Juniors.');
    End
  else if (year_level_students = 4) then
    Begin
    Writeln;
    Writeln('You are belong to Seniors.');
    End
  else
     Begin
     Writeln;
     Writeln('Invalid Year Level Try Again.');
     End;
  Readln;
End.

Age Checker in Pascal

In this article I would like to share with you a sample program that I wrote in Pascal to check if the given age of the user is already considered as an Adult or still a minor. I am using Turbo Pascal 5.0 as my compiler in this sample program.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.





Sample Program Output


Program Listing

Program Age;
Uses Crt;

Var Age_User  : Integer;

Begin
  Clrscr;
  Write('Age Checker in Pascal');
  writeln;
  writeln;
  Write('What is your age? ');
  readln(Age_User);

  if (Age_User >=18) then
    Begin
    Writeln;
    Writeln(Age_User, ' years old. You are already an Adult.');
    End
  else
     Begin
     Writeln;
     Writeln(Age_User, ' years old. You are still a Minor.');
     End;
  Readln;
End.

Positive and Negative Number Checker in Pascal

Hi there in this article I would like to share with you a sample program that I wrote using Pascal as my programming language to check if the given number by the user is a positive or negative number. In this sample program I am using Turbo Pascal 5.0 as my compiler.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.





Sample Program Output


Program Listing

Program Positive_Negative;
Uses Crt;

Var Number : Integer;

Begin
  Clrscr;
  Write('Positive and Negative Number Checker');
  writeln;
  writeln;
  Write('Enter a Number : ');
  readln(Number);

  if (number >=0) then
    Begin
    Writeln;
    Writeln(Number, ' is a Positive Number.');
    End
  else
     Begin
     Writeln;
     Writeln(Number, ' is a Negative Number.');
     End;
  Readln;
End.

Friday, August 5, 2016

Lower Case To Upper Case Converter in C++

A simple program that I wrote in C++ to covert lowercase to uppercase of string in C++.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.


Program Listing

#include <iostream>
#include <cctype>
#include <string>


int main()
{
    using namespace std;
    string str;

   cout << " Lower Case To Upper Case String Conversion 1.0";
   cout << "\n\n";
   cout << "Enter a String : ";
   getline(cin,str);
    for (size_t i = 0; i < str.length(); ++i)
    {
        str[i]=toupper(str[i]);
    }

    cout << "\n";
    cout<<"\n Converted Results in Upper Case : "  <<str << ".";
    for (size_t i = 0; i < str.length(); ++i)
    {
        str[i]=tolower(str[i]);
    }

    cout<<"\n Converted Results in Lower Case : "  <<str << ".";
    cout << "\n\n";
    system("PAUSE");

}

Addition of Five Numbers in Perl CGI

A sample program that I wrote that will compute the sum of the five numbers using Perl CGI it will display the result in the web page in your web browser.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Sample Program Output

Program Listing

#!"C:\xampp\perl\bin\perl.exe"
print "content-type: text/html \n\n";
print "<html>";
print "<body>";

$a=2;
$b=3;
$c=5;
$d =3;
$e = 2;

$sum = ($a + $b + $c + $d + $e);

print "<font color='blue'>";
print "<br>";
print " <h2> Addition of Five Numbers </h2>";
print "<font size='5'>The value in A is $a. </font><br>";
print "<font size='5'>The value in B is $b. </font><br>";
print "<font size='5'>The value in C is $c. </font><br>";
print "<font size='5'>The value in D is $d. </font><br>";
print "<font size='5'>The value in E is $e. </font><br>";

print "<br><br>";
print "<font size='5'>The sum of $a ,$b , $c, $d and $e is $sum. </font>";
print "</font>";
print "</body>";
print "</html>";


# test.pl
# if you are using xampp with installed perl interpreter
# save your file for example test.pl in the following 
# directories in xampp.  example  c:\xampp\cgi-bin\test.pl
# to run the script.
# Issue this command for example
#
# localhost:1234/cgi-bin/test.pl
##








HTML Form in Perl CGI

A simple program that I wrote in Perl CGI to show how to use HTML FORM to capture the user input and display the result in the same page. The code is very easy to understand and use.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.


Sample Program Output


Program Listing

#!"C:\xampp\perl\bin\perl.exe"
use strict;
use warnings;
use CGI qw(:all);

my $cgi = new CGI;
my $this_url = $cgi->url(); 
my $first = $cgi->param('first_name');
my $last = $cgi->param('last_name');
print "Content-type:text/html\n\n";
print <<EndOfHTML;
<html><head><title>Perl Same Page Display</title></head>
<style>
  body {
   font-family: arial;
   font-size: 18px;
   font-weight: bold;
 };
</style>
<body>
<FORM action="$this_url" method="POST">
<font color='green'>
What is your first name <input type="text" name="first_name" value='$first'>  <br>
What is you last name  <input type="text" name="last_name" value='$last'>
<br><br>
<input type="submit" value="Ok">
</FORM>
<p>Hello $first $last How are you today?</p> </font>
</body>
EndOfHTML



Math Calculator in Perl CGI

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.




Sample Program Output


Program Listing

<!-- 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";


















Positive and Negative Numbers in Perl CGI

A simple program that I wrote in Perl CGI to display the list of positive and negative numbers in the web page of the web browser. The code is very easy to understand and use.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

positive.cgi


#!"C:\xampp\perl\bin\perl.exe"


print "Content-type:text/html\n\n";
print "<font size='3'>";
printf "<font color='blue'>";
print "Positive and Negative Numbers in Perl";
print "<br><br>";

for (my $i=-10; $i <= 10; $i++) {
print "<font size='4'>";
printf "<font color='blue'>";
if ($i < 0) {
print "$i is a Negative Number";
print "<br />";
}
else {
  print "$i is a Positive Number";
print "<br />";
}
printf "</font> </font></font> </font>";

}




Odd and Even Numbers in Perl CGI

A simple program that I wrote in Perl CGI to display the odd and even numbers on the web browser.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

#!"C:\xampp\perl\bin\perl.exe"

print "Content-type:text/html\n\n";
print "ODD AND EVEN Numbers";
print "<br><br>";
for (my $i=0; $i <= 10; $i++) {
if ($i % 2 == 0) {
print "$i is an EVEN Number";
print "<br />";
}
else {
  print "$i is an ODD Number";
print "<br />";
}

}


Running Sum of Numbers in C++

A simple program that I wrote in C++ that will perform running sum of values provided by the user. The code is very easy to understand and use.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.


Program Listing

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int values[3][2], running_sum=0;
    
     cout << "\t\t RUNNING SUM VERSION 1.0";
     cout << "\n";
     cout << "\tCreated By: Mr. Jake R. Pomperada, MAED-IT"; 
          cout << "\n";
      for (int row=0; row< 3; row++) {
           for (int col=0; col< 2; col++) {

            cout << "\nEnter a Number :=> ";
            cin >> values[row][col];
          
            running_sum+=values[row][col];
            cout << "\nThe running sum is " <<       
                    running_sum << ".";
             }
             }
         cout << "\n\n";                     
    system("PAUSE");
    return EXIT_SUCCESS;
}


Roman Numeral To Decimal in PHP

A simple program that will convert the roman number into decimal equivalent in PHP.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

<html>
<title>Roman Numeral To Decimal in PHP</title>
<style>
  body {
   font-family: arial;
   font-size: 18px;
   font-weight: bold;
 };
</style>
<body>
  <?php
   error_reporting(0);
  $input_A = $_POST['inputFirst'];

  if(isset($_POST['ClearButton'])){
  $input_A="";

  $display_result="";
  }

   ?>
   <br>
  <h2>Roman Numeral To Decimal in PHP </h2>
<form action="" method="post">
   Enter Roman Numeral
  <input type="text" name="inputFirst"
  value="<?php echo $input_A; ?>" size="5" autofocus required/>

  <br><br>

  <input type="submit" name="SubmitButton" value="Ok"/>
   &nbsp;&nbsp;&nbsp;
  <input type="submit" name="ClearButton" value="Clear"/>
</form>
<?php

function roman_convert($input_roman){
  $di=array('I'=>1,
            'V'=>5,
            'X'=>10,
            'L'=>50,
            'C'=>100,
            'D'=>500,
            'M'=>1000);
  $result=0;
  if($input_roman=='') return $result;
    for($i=0;$i<strlen($input_roman);$i++){
    $result=(($i+1)<strlen($input_roman) and
          $di[$input_roman[$i]]<$di[$input_roman[$i+1]])?($result-$di[$input_roman[$i]])
                                                        :($result+$di[$input_roman[$i]]);
   }
 return $result;
}


if(isset($_POST['SubmitButton'])){

$original = $input_A;
$value = roman_convert($input_A);

  echo "<br>";
  $display_result = "The Decimal equivalent of " .$original. " is "
                    .$value.".";

  echo $display_result;
  echo "<br>";
 }
?>

</body>
</html>