Sunday, November 29, 2015

Ordinal Values in PHP

This sample program that I wrote in PHP as programming language to create the ordinal values. The code is very simple and easy to understand. I intended my work for beginners in PHP programming.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

<?php
echo "<br>";
echo "<font face='arial'>";
echo "<h2 align='center'> Ordinal Values in PHP </h2> </font>";
echo "<br>";
for ($a=1; $a<=100; $a++) {

 $mod100 = $a % 100;
 $mod10 = $a % 10;

if ($mod10 == 1 && $mod100 != 11) {

   $message= "st";

} else if  ($mod10 == 2 && $mod100 != 12) {
 $message="nd";
}
else if  ($mod10 == 3 && $mod100 != 13) {
$message= "rd";
} else {
 $message= "th";
 }


 echo "<font face='arial' size='5'>";
 echo " ".$a.$message."</font>";
}

?>

Thursday, November 26, 2015

Simple Interest Solver in PHP

A simple program that I wrote in PHP to compute the interest rate of a loan of a customer or client. The code is very simple and easy to understand good for beginners in PHP programming.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.


Sample Program Output


Program Listing

<?php

  error_reporting(0);

$principle = $_POST['principle'];
$rate = $_POST['rate'];
$time = $_POST['time'];


 if ($_POST['clear'])
   {
   $principle = "";
   $rate = "";
   $time = "";
   $display_results = "";
}


  if  ($_POST['compute']) 
  {
   $interest =($principle*$rate*$time)/100;
   $display_results = round($interest,2);
 }

?>
<html>
 <style>
 body {
  font-family:arial;
  font-size:12;
  }
</style>   
<title> Simple Interest Solver in PHP</title>
<form action = "" method = "POST">
<body>
<h2> Simple Interest Solver in PHP </h2>
<br>
<table border = 3>
<tr>
   <td> Principle Amount : </td>
   <td> <input type = text name = "principle" value = "<?php echo $principle;?>"  size="10" autofocus>
   </tr>
   <tr>
   <td> Rate of Interest : </td>
   <td> <input type = text name = "rate" value = "<?php echo $rate;?>"  size="5">
   </tr>
   <tr>
   <td> Time Period : </td>
   <td> <input type = text name = "time" value = "<?php echo $time;?>" size="10"  >
   </tr>
   <tr>
     <td> &nbsp; </td>
    </tr>
   <tr>
   <td>Interest Rate Php </td>
   <td> <input type = text name = "solve_interest" value = "<?php echo $display_results;?>" size="12" readonly >
   </tr>
   <tr>
     <td> &nbsp; </td>
    </tr>
   <td colspan = 3>
        <input type = "submit" name="compute" value = "Compute Interest" title="Click here to compute for interest rate.">
        <input type = "submit" name="clear" value = "Clear" title="Click here to clear text boxes.">
   </td>
   </tr>
   </table>
   </form>
     </body>
   </html>








Display the result in the same page in PHP

In this sample program I would like to share with you how to create a program that will accept input values from the user and then display the values in PHP using the same page. The code is very simple and easy to understand ideal for beginners in PHP programming.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing


<?php
error_reporting(0);
$fname = $_POST['fn'];
$age = $_POST['a'];
$course = $_POST['crs'];
 
 
 if ($_POST['clear'])
   {
    
  $fname="";
  $age="";
  $course="";
  $message1="";
  $message2="";
}


  if  ($_POST['send']) 
  {
    $message1 = "Hello " .$fname;
    $message2 = "Your are $age years old and your course is $course.";
    
}


?>
<html>
 <style>
 body {
  font-family:arial;
  font-size:12;
  }
</style>   
<title> BUILT IN FUNCTIONS</title>
<form action = "" method = "POST">
<body>
<table border = 3>
<tr>
   <td> Name: </td>
   <td> <input type = text name = fn value = "<?php echo $fname;?>"  size="50" autofocus>
   </tr>
   <tr>
   <td> Age: </td>
   <td> <input type = text name = a value = "<?php echo $age;?>"  size="3">
   </tr>
   <tr>
   <td> Course: </td>
   <td> <input type = text name = crs value = "<?php echo $course;?>" size="50"  >
   </tr>
   <tr>
   <td colspan = 3>
        <input type = "submit" name="send" value = "Ok" title="Click here to display values.">
        <input type = "submit" name="clear" value = "Clear" title="Click here to clear text boxes.">
   </td>
   </tr>
   </table>
   </form>
  <?php
     echo "<br><br>";
    echo "<font face='arial' size='4'>";
    echo  $message1;
    echo "<br>";
    echo $message2;
    echo "</font>";
  ?>  
   </body>
   </html>

 

Wednesday, November 25, 2015

Square a value in C++

A simple program that I wrote in C++ that will square a number based on the number given by the user.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.


Program Listing


#include <iostream>
#include <iomanip>

 using namespace std;

// Global Variable

int values[6],a=0;

 void accept_data(void);
 void display_result(void);

 void accept_data()
 {
    for (a=1; a<=5; a+=1) {
          cout << "Enter Value No. "
               << a << " : ";
           cin >> a[values];
      }
 }

 void display_result()
 {
            cout << "\n\n";
            cout << setw(5)
                 << "VALUES"
                 << setw(18)
                 << "SQUARE VALUES";
            cout << "\n\n";
            for (a=1; a<=5; a+=1) {

           cout <<"\n" << setw(3) << a[values]
                << setw(16)
                << a[values] * a[values];
           }
        cout << "\n\n";
        system("pause");
 }
main() {

     cout << "\n\n";
     cout << "\t\t Square A Value Version 1.0";
     cout << "\n\n\n";

    accept_data();
    display_result();
 }


Simple Interest Solver In Pascal

A simple loan interest solver that I wrote using Pascal as my programming language that will solve for the interest rate of the loan of a person. I am using Turbo Pascal 5.5 For DOS as my Pascal compiler.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Listing


Program Listing


Program Simple_Interest_Solver;
Uses Crt;

Var p,r,t,solve_interest : Real;

Begin
  p:=0.00;
  r:=0.00;
  t:=0;
  solve_interest := 0.00;

  clrscr;

  write('Simple Interest Solver');
  writeln; writeln;
  write('Enter the Principle Amount : Php ');
  readln(p);
  write('Enter the Rate of Interest :     ');
  readln(r);
  write('Enter the Time Period      :     ');
  readln(t);

  solve_interest:=(p*r*t)/100;

  writeln; writeln;
  write('The simple interest is Php ',solve_interest:5:2,'.');
  writeln; writeln;
  write('End of Program');
  readln;
End.

Simple Math Calculator in Pascal

A simple math calculator that I wrote in Pascal programming language that will ask the user to give two numbers and then the user will select the operand either plus, subtract, multiplication and division mathematical operations. I am using Turbo Pascal 5.5 For DOS as my pascal compiler in this sample program.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.




Sample Program Output

Program Listing


Program Basic_Calculator;
Uses Crt;

Var

 Operator   : Char;
 Opt1,Opt2  : Integer;
 Sum,Subtract, Multiply: Integer;
 Divide     : Integer;
 Result     : Integer;

Begin

  clrscr;
  Opt1 := 0; Opt2 := 0;

  write('Simple Math Calculator');
  writeln; writeln;
  write('Enter Two Numbers : ');
  readln(Opt1,Opt2);
  write('Select Operators +,-,* and / : ');
  readln(Operator);
  if (Operator = '+') then
    Begin
      Sum := (Opt1 + Opt2);
      Result := Sum;
    End


   else if (Operator = '-') then
    Begin
      Subtract := (Opt1 - Opt2);
      Result := Subtract;

    End

   else if (Operator = '*') then
    Begin
      Multiply := (Opt1 * Opt2);
      Result := Multiply;

    End

   else if (Operator = '/') then
    Begin
      Divide := (Opt1 DIV Opt2);
      Result := Divide;

    End;


  writeln;
  writeln;
  Write('The result is ' ,Result,'.');
  readln;

End.







Consonants and Vowels Counter in C

A sample program that will ask the user to enter a work or a sentence and then the program will count how many consonants and vowels in a given word or sentence by the user. Take note I am using Turbo C 2.0 For DOS as my C compiler in this program.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.




Sample Program Output

Program Listing

/* Consonants and Vowels Counter               */
/* Written By: Mr. Jake R. Pomperada, MAED-IT  */
/* Date  : November 25, 2015                   */
/* Tools : Turbo C 2.0  For DOS                */

#include <stdio.h>
#include <ctype.h>
#include <conio.h>

  main()
    {
char strings[200];
int vowels=0,consonants=0,i=0;
clrscr();
printf("Enter a word or sentence : ");
gets(strings);

while(strings[i] != '\0')
{
if (toupper(strings[i])=='A' || toupper(strings[i])=='E' ||
toupper(strings[i])=='I' ||  toupper(strings[i])=='O'||
toupper(strings[i])=='U')

vowels++;



  if (toupper(strings[i])=='B' || toupper(strings[i])=='C' ||
toupper(strings[i])=='D' || toupper(strings[i])=='F'||
toupper(strings[i])=='G' || toupper(strings[i])=='H' ||
toupper(strings[i])=='J' || toupper(strings[i])=='K'||
toupper(strings[i])=='L' || toupper(strings[i])=='M' ||
toupper(strings[i])=='N' || toupper(strings[i])=='P'||
toupper(strings[i])=='Q' || toupper(strings[i])=='R' ||
toupper(strings[i])=='S' || toupper(strings[i])=='T'||
toupper(strings[i])=='V' || toupper(strings[i])=='W' ||
toupper(strings[i])=='X' || toupper(strings[i])=='Y' || 
                toupper(strings[i])=='Z')

consonants++;

i++;
}
printf("\n\n");
printf("===== DISPLAY RESULTS =====");
printf("\n\n");
printf("Total Number of Vowels     : %d. ", vowels);
printf("\n\n");
printf("Total Number of Consonants : %d.   ",consonants);
getch();
}



Simple Interest Rate Solver in C

A simple program that I wrote in C language that will compute for the interest rate of a loan. I am using Turbo C 2.0 for DOS as my C compiler in this sample program.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.




Program Listing

#include <stdio.h>
#include <conio.h>

main()
{

float principal,rate,time,solve_interest;

principal=0.00;
rate=0.00;
time=0.00;
solve_interest=0.00;

clrscr();
printf("\tSimple Interest Rate Solver");
printf("\n\n");
printf("Enter the Principle Amount Loaned : Php ");
scanf("%f",&principal);
printf("Enter the Rate of Interest        : ");
scanf("%f",&rate);
printf("Enter the Time Period             : ");
scanf("%f",&time);

solve_interest = (principal*rate*time)/100;

printf("\n\n");
printf("The simple interest is Php %5.2f.",solve_interest);
printf("\n\n");
printf("\t End of Program");
getche();
}

Tuesday, November 24, 2015

Student Grade Solver in JavaScript

A simple program that I wrote using JavaScript that will ask the name and the grades of the student in the several subject and then our program will compute for the average grade of the student using JavaScript as our programming language and then generate a grade sheet report afterwards.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing


<html>
<head>
<title> Student Grade Solver in JavaScript </title>
<script language = "Javascript">

function Average(eng,math,theo,sci,his)
{
ave = (eng+math+theo+sci+his)/5;
return(ave);
}
var studname = prompt ("Enter Student Name:","");
var gr_eng = parseInt (prompt ("Enter grade in English:"," "));
var gr_math = parseInt (prompt ("Enter grade in Math:"," "));
var gr_theo = parseInt (prompt ("Enter grade in Theology:"," "));
var gr_sci = parseInt (prompt ("Enter grade in Science:"," "));
var gr_his = parseInt (prompt ("Enter grade in History:"," "));
var ave=Average(gr_eng,gr_math,gr_theo,gr_sci,gr_his);

document.write ("<center><h1> STUDENT GRADE SHEET </h1><hr width='75%' color='blue' size='3'>");
document.write ("<table><tr><td>Student<td>Name:<td><b>",studname,"</b>");
document.write ("<tr><td><b><u>Subject:</b></u><td><br>");
document.write ("<tr><td><br><td> English:<td>",gr_eng);
document.write ("<tr><td><br><td> Math:<td>",gr_math);
document.write ("<tr><td><br><td> Theology:<td>",gr_theo);
document.write ("<tr><td><br><td> Science:<td>",gr_sci);
document.write ("<tr><td><br><td> History:<td>",gr_his);
document.write ("<tr><td>Average<td>Grade:<td><b><p>",ave,"</b>");
if (ave >= 75)
{
status = "Passed";
}
else
{
status = "Failed";
}
document.write ("<tr><td>Status:<td><br><td><b>",status,"</b></table><hr width=75% color='blue' size=3>"); 
</script>
</head>

<body bgcolor = "green" text = "white">

</body>
</html>

Calculator in JavaScript

A simple calculator that I wrote before using JavaScript as my programming language. The code is very simple and easy to understand.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.


Sample Program Output


Program Listing

<html>
<head>
<title>Calculator</title>
<script language = "Javascript">
var a = "";
var b = "";

function compute(x)
{
  if (a == "")
  {
    b = document.calc.num.value + x;
    document.calc.num.value = b;
  }
  else
  {
    a = document.calc.num.value + x;
    document.calc.num.value = a;
  }
}
function equals()
{
  a = eval(document.calc.num.value);
  document.calc.num.value = a;
}
</script>
</head>
<body bgcolor = "#336699" text = "white">
<center>
<form name = "calc">
<br><br>
<input type = "text" name ="num"> </input><br><br>
<input type = "button" name = "btnadd" value = " + " onclick = compute("+")> </input> &nbsp;&nbsp;
<input type = "button" name = "btnsub" value = " - " onclick = compute("-")> </input> &nbsp;&nbsp;
<input type = "button" name = "btnmul" value = " * " onclick = compute("*")> </input> &nbsp;&nbsp;
<input type = "button" name = "btndiv" value = " / " onclick = compute("/")> </input> <br><br>
<input type = "button" name = "btn0" value = " 0 " onclick = compute("0")> </input> &nbsp;&nbsp;
<input type = "button" name = "btn1" value = " 1 " onclick = compute("1")> </input> &nbsp;&nbsp;
<input type = "button" name = "btn2" value = " 2 " onclick = compute("2")> </input> &nbsp;&nbsp;
<input type = "button" name = "btn3" value = " 3 " onclick = compute("3")> </input> &nbsp;&nbsp;
<input type = "button" name = "btn4" value = " 4 " onclick = compute("4")> </input> <br><br>
<input type = "button" name = "btn5" value = " 5 " onclick = compute("5")> </input> &nbsp;&nbsp;
<input type = "button" name = "btn6" value = " 6 " onclick = compute("6")> </input> &nbsp;&nbsp;
<input type = "button" name = "btn7" value = " 7 " onclick = compute("7")> </input> &nbsp;&nbsp;
<input type = "button" name = "btn8" value = " 8 " onclick = compute("8")> </input> &nbsp;&nbsp;
<input type = "button" name = "btn9" value = " 9 " onclick = compute("9")> </input> 

<br><br>
<input type = "button" name = "btnperiod" value = " . " onclick = compute(".")> </input> &nbsp;&nbsp;
<input type = "reset" value = " Clear "> </input> &nbsp;&nbsp;
<input type = "button" name = "btnequal" value = " = " onclick = equals()> </input> 
</form>
</center>
</body>
</html>

Ordinal Number Generator in C++

A program that I wrote using C++ as my programming language that will ask the user to enter or give a number and then our program will generate the corresponding ordinal numbers. In this program I am using CodeBlocks 8.02 as my editor and Dev C++ as my compiler that is already integrated with CodeBlocks 8.02.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

// ordinal.cpp
// Written By: Mr. Jake R. Pomperada, MAED-IT
// Tools : CodeBlocks 8.02
// Date  : November 24, 2015


#include <iostream>

using namespace std;

int test(int i) {

char *message;
int a=0, mod100 = 0, mod10 = 0;

cout << "\n";
for (a=1; a<=i; a++) {

 mod100 = (a % 100);
 mod10 = (a % 10);

if (mod10 == 1 && mod100 != 11) {

   message= "st";

} else if  (mod10 == 2 && mod100 != 12) {
 message="nd";
}
else if  (mod10 == 3 && mod100 != 13) {
message= "rd";
} else {
 message= "th";
 }
 cout <<" " << a << message << " ";
}

}

main(){

  int number=0;

  cout << "\n";
  cout <<"\t Ordinal Number Generator in C++";
  cout << "\n\n";
  cout << "Enter a Number : ";
  cin >> number;

  test(number);

  cout <<"\n\n";
  cout << "End of the Program";
  cout << "\n\n";
}