Wednesday, November 25, 2015

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



Ordinal Number Generator in C

A program that I wrote using C as my programming language that will ask the user to give a number and then our program will generate the ordinal numerical values in a given number by our user. In this sample program I am using Turbo C 2.0 For DOS that is widely available free to download over the Internet.


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


/* ordinal.c */
/* Written By: Mr. Jake R. Pomperada, MAED-IT */
/* Tools : Turbo C 2.0 For DOS                */
/* Date  : November 24, 2015                 */


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

int test(int i) {

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

printf("\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";
 }

 cprintf(" %d%s  " ,a,message);
 delay(2000);
}

}

main(){

  int number=0;

  clrscr();
  textcolor(WHITE);
  printf("\n");
  cprintf("Ordinal Number Generator in C");
  printf("\n\n");
  cprintf("Enter a number : ");
  scanf("%d",&number);

  test(number);

  printf("\n\n");
  cprintf(" End of Program");
  getche();
}


Ordinal Number Generator in Java

This program will accept an input numerical value from the user and then it will generate the corresponding ordinal number based on the given number by the user using Java as our programming language.

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

import java.util.Scanner;


class ordinal3 {

public static String ordinal(int c) {

    int r100 = (c % 100);

    int r10 = (c % 10);

    if(r10 == 1 && r100 != 11) {
        return c + "st";
    } else if(r10 == 2 && r100 != 12) {
        return c + "nd";
    } else if(r10 == 3 && r100 != 13) {
        return c + "rd";
    } else {
        return c + "th";
    }
}


public static void main(String[] args) {

int values=0;

Scanner in = new Scanner(System.in);
System.out.print("\n\n"); 
System.out.print("\t Ordinal Number Generator");
System.out.print("\n\n");
System.out.print("Enter an integer :=> ");


values = in.nextInt();
System.out.print("\n\n");
  for (int a=1; a<=values; a++)
   {
    
      System.out.print(" " +ordinal(a)+ " ");
    }
  
   System.out.print("\n\n");
   System.out.print("End of Program ");
   System.out.print("\n\n");
    }
 }

Ordinal Numbers Using Pascal

As I learned computer programming my first programming language that I have learned is Pascal my compiler that I am using during those days in college in Turbo Pascal 5.0. In this program I would like to reminisce the past by writing a program using Pascal as my programming language to accept a number from the user and then convert the number into ordinal equivalent values.

In this sample program I am using Turbo Pascal 5.5 that is widely available right now to download free from any charges over the Internet. This problem I encounter during my college day's in our programming class.  





Sample Program Output


Program Listing


(* Ordinal_Numbers.pas                       *)
(* Written By Mr. Jake R. Pomperada, MAED-IT *)
(* Tools : Turbo Pascal 5.5. For DOS         *)
(* Date  : November 24, 2015                 *)

Program Ordinal_Numbers;
Uses Crt;

Var number : integer;

  message  : string;
  a              : integer;
  mod100   : integer;
  mod10    : integer;

begin
   a:=0; mod10:=0; mod100:=0;

  clrscr;
  textcolor(yellow);
  write('Ordinal Number Generator in Pascal');
  writeln; writeln; writeln;
  write('Enter a Number : ');
  readln(number);
  writeln; writeln;
  for a:= 1 To number Do
   Begin
     mod10 := (a mod 10);
     mod100 := (a mod 100);

   if (mod10 = 1) AND (mod100 <> 11) then
     Begin
       message := 'st';
     End

   else if (mod10 = 2) AND (mod100 <> 12) then
     Begin
       message := 'nd';
     End

   else  if (mod10 = 1) AND (mod100 <> 11) then
     Begin
       message := 'rd';
     End
  else
    Begin
     message := 'th';
    End;

        write(' ',a,message,' ');
   End;

  writeln; writeln;
  write('End of Program');
  readln;
End.


Sunday, November 22, 2015

Ordinal Number in Visual Basic 6

A sample program that I wrote using Microsoft Visual Basic 6 to check if the given number is an ordinal  number or not. The code is very simple and easy to understand for beginners that are new in Visual Basic 6 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


Public Function ordinal(Number As String) As String
    If Number = "11" Or Number = "13" Then
     ordinal = Number & "th"
    ElseIf Number = "1" Then
        ordinal = Number & "st"
    ElseIf Number = "2" Then
        ordinal = Number & "nd"
    ElseIf Number = "3" Then
        ordinal = Number & "rd"
    Else: ordinal = Number & "th"
    End If
End Function


Private Sub Command1_Click()
num = ordinal(Form1.Text1.Text)
MsgBox ("The ordinal value of " & Form1.Text1.Text & " is " _
 & num & ".")
End Sub




Ordinal Number Generator in JavaScript

A program that I wrote in JavaScript that will generate ordinal numbers 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.



Sample Program Output


Program Listing

<html>
 <head>
<title> Ordinal Number Generator in JavaScript </title>
<style>
body {
    font-family:arial;
size:12;
}
</style>
</head>
<body>
<h3 align="center"> Ordinal Number Generator in JavaScript </h3>
<script>

function ordinal(num_values) {
   var str_values=["th","st","nd","rd"];
       values=num_values%100;
   return num_values+(str_values[(values-20)%10]||str_values[values]||str_values[0]);
}
   
var number = parseInt(prompt("Enter a number"));
var a;

for (a=1; a<=number; a++)
{
document.write("<font face='arial' size='4'>");
document.write("&nbsp;" +ordinal(a) + " </font>");
}
</script>
</body>
</html>



Saturday, November 21, 2015

Greatest Common Denominator in JavaScript


A simple program that I wrote in JavaScript that will compute the Greatest Common Denominator. 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> Greatest Common Denominator </title>
  </head>
  <style>
  h3 {
     font-family:arial;
 </style>
 <body> 
 <h3> Greatest Common Denominator </h3>
 <script>

 function GCD(nums)
{
        if(!nums.length)
                return 0;
        for(var r, a, i = nums.length - 1, GCDNum = nums[i]; i;)
                for(a = nums[--i]; r = a % GCDNum; a = GCDNum, GCDNum = r);
        return GCDNum;
}

 val_1 = Number(prompt("Enter First Number  : "));
 val_2 = Number(prompt("Enter Second Number : "));
 val_3 = Number(prompt("Enter Third Number  : "));
 
document.write("<font face='arial' face='14'> <b>");
document.write("The Greatest Common Denomination of " + val_1 + "," + val_2 
 + " and " +val_3 + " is " + GCD([val_1, val_2, val_3])+". <b></font>"); 
</script>
</body>
</html>

 

Counting Sort in JavaScript

This program will show you how to implement Counting Sort algorithm using JavaScript programming language.

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

<html>
 <head>
   <title>Counting Sort</title>
  </head>
<body> 
   <script>

   var values=[],a=[];
   var temp=0,pos=0;
   
   document.write("<font face='arial' size='4'>COUNTING SORT </font>");
   document.write("<br><br>");
 for (a=0; a<10; a++) {
  values.push(Number(prompt("Enter item value at no. " + (a+1))));
   }
      document.write("<font face='arial' size='4'>Numbers");
     document.write(" given by the user </font>");
     document.write("<br><br>");
  for (a=0;a<10; a++) {
    document.write("<font face='arial' size='4'> " +values[a] + "");
   }
 

 function counting_sort(arr, min, max) {
    var i, z = 0, count = [];
    for (i = min; i <= max; i++) {
        count[i] = 0;
    }
    for (i=0; i < arr.length; i++) {
        count[arr[i]]++;
    }
    for (i = min; i <= max; i++) {
        while (count[i]-- > 0) {
            arr[z++] = i;
        }
    }
    return arr;
}

       counting_sort(values,0,10);
    
      document.write("<br><br>");
 document.write("<font face='arial' size='4'>Sorted List of Numbers </font>");
 document.write("<br><br>");
 
  for (a=0; a<10; a++) {
    document.write("<font face='arial' size='4'> " +  values[a]+"</font>");
  }  
  </script>
  </body>
 </html>