Saturday, April 9, 2016

Kilometers To Miles Converter in Python

In this simple program it will ask the user to give the distance in kilometers and then our program will convert the given distance in miles into kilometers equivalent using Python as my programming language.

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

def my_program():
   print()
   print("KILOMETERS TO MILES CONVERTER")
   print()
   kilometers = float(input("How many kilometer(s) ? : "))
   print()
   miles = (kilometers *  0.621371)
   print('%0.2f Kilometers(s) is equal to %0.2f Mile(s).' %(kilometers,miles))
   print("\n");
   repeat = input('Do you want to continue ? (Y/N) : ')

   if repeat.upper() == "N":
       print("\n")
       print("END OF PROGRAM")
       quit
   if repeat.upper() == "Y":
       my_program()

if __name__ == '__main__':
       my_program()





Miles To Kilometers Converter in Python

In this simple program it will ask the user to give the distance in Miles and then our program will convert the given distance in miles into kilometers equivalent using Python as my programming language.

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

def my_program():
   print()
   print("MILES TO KILOMETERS CONVERTER")
   print()
   miles = float(input("How many miles? : "))
   print()
   kilometers = (miles * 1.60934)
   print('%0.2f Mile(s) is equal to %0.2f Kilometer(s).' %(miles,kilometers))
   print("\n");
   repeat = input('Do you want to continue ? (Y/N) : ')

   if repeat.upper() == "N":
       print("\n")
       print("END OF PROGRAM")
       quit
   if repeat.upper() == "Y":
       my_program()

if __name__ == '__main__':
       my_program()


Cube Numbers in Python

A simple program that I wrote using Python as my programming language that will ask the user to give a number and then our program will convert the give number by the user into cube number equivalent.

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


def my_program():
   print()
   print("CUBE NUMBERS PROGRAM")
   print()
   number = int(input("Enter a Number : "))
   print()
   solve_cube = (number * number * number)
   print("The cube value of ",number, " is "
          ,solve_cube,".")
   print("\n");
   repeat = input('Do you want to continue ? (Y/N) : ')

   if repeat.upper() == "N":
       print("\n")
       print("END OF PROGRAM")
       quit
   if repeat.upper() == "Y":
       my_program()

if __name__ == '__main__':
       my_program()



Consonants Remover in Python


A simple program that  I wrote using Python as my programming language that will ask the user to give a word or a sentence and then our program will remove the consonants in the given word or a sentence by the 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

def my_program():
   print()
   print("REMOVE CONSONANTS PROGRAM")
   print()
   str = input("Enter a String : ")
   print()
   consonants = ['b', 'c', 'd', 'f', 'g',
                 'h','j','k','l','m','n',
                 'p','q','r','s','t','v',
                 'w','x','y','z']
   result = ''
   for letter in str.lower():
      if letter not in consonants:
       result += letter
   print("The result is " ,result.upper(),".")
   print("\n");
   repeat = input('Do you want to continue ? (Y/N) : ')

   if repeat.upper() == "N":
       print("\n")
       print("END OF PROGRAM")
       quit
   if repeat.upper() == "Y":
       my_program()

if __name__ == '__main__':
       my_program()





Remove Vowels in Python

A simple program that  I wrote using Python as my programming language that will ask the user to give a word or a sentence and then our program will remove the vowels in the given word or a sentence.

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


def my_program():
   print()
   print("REMOVE VOWELS PROGRAM")
   print()
   str = input("Enter a String : ")
   print()
   vowels = ['a', 'e', 'i', 'o', 'u']
   result = ''
   for letter in str.lower():
      if letter not in vowels:
       result += letter
   print("The result is " ,result.upper(),".")
   print("\n");
   repeat = input('Do you want to continue ? (Y/N) : ')

   if repeat.upper() == "N":
       print("\n")
       print("END OF PROGRAM")
       quit
   if repeat.upper() == "Y":
       my_program()

if __name__ == '__main__':
       my_program()



Saturday, April 2, 2016

Array in JavaScript

A very simple program to demonstrate how to declare and use array using JavaScript as our programming language.

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

<html>
    <head>
        <title>Array in JavaScript</title>
    <head>
     <h1> Array in JavaScript </h1>
     <br> 
    </body>
        
        <script>

            var arrayOfFruits = ['Apple', 'Banana', 'Grapes', 'Orange','Guava','Dalandan'];
                
   
            alert(arrayOfFruits[2]);
            alert('length: ' + arrayOfFruits.length);            
        </script>
</html>

Focus Function in JavaScript

A simple program in JavaScript that shows how to use focus method in a program. The code is very basic and easy to understand for beginners that are new in JavaScript programming.

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

<html>
    <head>
        <title> Focus method in JavaScript</title>
    <head>
         <h1> Focus Method in JavaScript </h1>
         <br>
    <body>      
    
        <input type="text" id="txtName"/>
        &nbsp;&nbsp;
        <input
               type = "button"
               id = "btnCompute"
               onclick = "Compute();"
               value = "Compute"/>
    </body>
        
    <script>
        function Compute() {
            var txtName = document.getElementById("txtName");
            var name = txtName.value;
            
            if (name.trim() == "") {
                alert("Please enter value for name. ");
                txtName.focus;
                
            } else {
                alert("Hello " + name + " ! ");
            }
        }
    </script>
</html>

High, Middle and Low Number Determiner in C++

This program will determine which of the three numbers given by our user is the Highest, Middle and Lowest Number in C++ just using if else statement and relational operator. The code is very simple and easy to understand.

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.h>

using namespace std;

int high_number(int value1,int value2, int value3) {

  int high_value=0,low_value=0,middle_value=0;

   // Check For Higher Number

  if (value1 >= value2 && value1 >= value3) {
        high_value = value1;

    }

    else if (value2 >= value1 && value2 >= value3) {
        high_value = value2;
    }

    else if (value3 >= value1 && value3 >= value2) {
        high_value = value3;
    }


// Check For Low Number

  if (value1 <= value2 && value1 <= value3) {
        low_value = value1;
    }

    else if (value2 <= value1 && value2 <= value3) {
        low_value = value2;
    }
    else if (value3 <= value1 && value3 <= value2) {
        low_value = value3;
    }


 // Check For Middle Value
 
  if (value1 <= value2 && value1 >= value3 ) 
         {
        
        middle_value = value1;
    }
else  if (value2 <= value1 && value2 >= value3) 
      
         {
        
        middle_value = value2;
    }
else  if (value3 <= value1 && value3 >= value2) 
         {
        
        middle_value = value3;
    }

// Code for check all the possible arrangement of values

 // Check for 1 value   
else  if (value1 >= value2 && value1 <= value3) 
         {
        
        middle_value = value1;
    }

 // Check for 2 value   
else  if (value2 >= value1 && value2 <= value3) 
         {
        
        middle_value = value2;
    }


 // Check for 3 value   
else  if (value3 >= value1 && value3 <= value2) 
         {
        
        middle_value = value3;
    }

    cout << "\n\n";
    cout <<"\n" << high_value << " is the biggest number.";
   cout <<"\n" << middle_value << " is the middle number.";
   cout << "\n" << low_value << " is the lowest number.";
    cout << "\n\n";
}

main() {

    int a=0,b=0,c=0;

    cout << "\t High, Middle and Low Number Determiner 1.0";
    cout << "\n\n \t Created By: Mr. Jake R. Pomperada,MAED-IT";
    cout << "\n\n"; 
    cout << "Enter a Number : ";
    cin >> a;
    cout << "Enter a Number : ";
    cin >> b;
    cout << "Enter a Number : ";
    cin >> c;
    high_number(a,b,c);
    system("PAUSE");

}




Prime Number Generator in C++

A simple program that I wrote using C++ as my programming language that will ask the user to give a number and then the program will generate the corresponding prime numbers based from the number give by our user. I wrote a function for prime number generation in this sample program of ours.

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.h>


 int check_prime(int x)
 {
 int var1=0,var2=0,flag=0;
 cout << "\n\n";
 cout << "\t List of Prime Numbers";
 cout << "\n\n";
 for(var1 = 2; var1 <= x; var1++){
flag = 1;
for(var2 = 2; var2 < var1; var2++){
if((int)var1 % (int)var2 == 0){
flag = 0;
}
}
if(flag == 1){
cout << var2;
cout << " ";
}
}
 }
 main(){


   int values=0;
   cout << "\t\tPrime Number Generator Version 1.0";
   cout << "\n\n";
   cout << "Enter a Number : ";
   cin >> values;

   check_prime(values);
cout << "\n\n";
system("pause");
}


Thursday, March 31, 2016

Simple Leap Year Checker in JavaScript

Here is a very simple leaper year checker that I wrote using JavaScipt as my programming language. The code is very ideal for beginners in JavaScript Programming.

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

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

<html>
<head>
  <title>Simple Leap Year Checker in JavaScript</title>
  <script language = "JavaScript">
    x=1900;
str=x+" is a ";
str1="";
if (x%400==0)
 str1="leap year";
else if (x%4==0 && x%100!=0)
 str1="leap year";
else
 str1="not a leap year";
document.write(str+str1);
  </script>
</head>
</html>


Getting User Input From JavaScript

A simple program that I wrote using JavaScript that shows how get input values from the user using text box in HTML and submit those values using buttons in HTML into JavaScript. I intended my work for beginners in JavaScript programming this code is most common problem encounters by beginners in JavaScript. I hope this simple code will help them getting started.

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

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>

<style>
body {
font-family:arial;
  font-size:20px;
  font-weight:bold;
  color:blue;
}
p {
  font-family:arial;
  font-size:20px;
  font-weight:bold;
  color: green;
  }
</style>  
<body>
Enter your name
<input type="text" id="name" size="20" maxlength="20" required>
<br><br>
<button onclick="Greet(this);"> Ok </button> &nbsp;&nbsp;&nbsp;&nbsp;
<button onclick="Clear(this);"> Clear </button>
<br>
<p id="display"> </p>

<script>
function Greet(field)
{
var hello;
var field = document.getElementById('name');

if (field.value == '') {
 alert("Field is empty");
 document.getElementById('name').value="";
 document.getElementById('name').focus();
 }
 else {
 hello = "Hello " + field.value;
 document.getElementById("display").innerHTML = hello;
  }
}

function Clear(field)
{
var hello;
var field = document.getElementById('name');

if (field.value == '') {
 alert("Field is empty");
 document.getElementById('name').value="";
 document.getElementById('name').focus();
  }
 else { 
 document.getElementById('name').value =" ";
 document.getElementById("display").innerHTML = "";
 document.getElementById('name').focus();
 }
}
</script>
</body>
<html>


Math Calculator in JavaScript

A simple math calculator that I wrote using JavaScript as my programming language what the program does is that it will ask the user to give two integer number and then our program will find the sum, difference, product and quotient of the two number given by the user.

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

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>
<style>
body {
  background-color:lightgreen;
  font-family:arial;
  font-size:20px;
  font-weight:bold;
  color:blue;
}
p {
  font-family:arial;
  font-size:20px;
  font-weight:bold;
  color: blue;
  }
  
div.text { 
  margin: 0; 
  padding: 0; 
  padding-bottom: 1.25em; 

div.text label { 
  margin: 0; 
  padding: 0; 
  display: block; 
  font-size: 100%; 
  padding-top: .1em; 
  padding-right: 2em; 
  width: 8em; 
  text-align: right; 
  float: left; 

div.text input, 
div.text textarea { 
  margin: 0; 
  padding: 0; 
  display: block; 
  font-size: 100%; 

input:active, 
input:focus, 
input:hover, 
textarea:active, 
textarea:focus, 
textarea:hover { 
  background-color: lightyellow; 
  border-color: yellow; 

</style>  
<body><br>
<h2 align="left"> Simple Math Calculator </h2>
<br>
<div class="text"> 
    <label for="val1">Item Value No. 1</label> 
    <input type="text" size="5" name="val1" id="val1" maxlength="5"/> 
</div> 

<div class="text"> 
    <label for="val2">Item Value No. 2</label> 
    <input type="text" size="5" name="val2" id="val2" maxlength="5"/> 
</div> 
<button onclick="compute()" title="Click here to find the result."> Ok </button> &nbsp;&nbsp;&nbsp;&nbsp;
<button onclick="clear_all()" title="Click here to clear the text fields."> Clear </button>
<br><br><br>
<p id="display1"> </p>
<p id="display2"> </p>
<p id="display3"> </p>
<p id="display4"> </p>

<script>
function compute()
{

var val1 = document.getElementById('val1').value;
var val2 = document.getElementById('val2').value;

var sum = parseInt(val1) + parseInt(val2);
var subtract = parseInt(val1) - parseInt(val2);
var product = parseInt(val1) * parseInt(val2);
var quotient = parseInt(val1) / parseInt(val2);


 document.getElementById("display1").innerHTML = "The sum of " + val1 + " and " + val2 + " is " + sum + ".";
 document.getElementById("display2").innerHTML = "The difference between " + val1 + " and " + val2 + " is " + subtract + ".";
 document.getElementById("display3").innerHTML = "The product between " + val1 + " and " + val2 + " is " + product + ".";
 document.getElementById("display4").innerHTML = "The quotient between " + val1 + " and " + val2 + " is " + quotient + ".";

}

function clear_all()
{
document.getElementById("display1").innerHTML ="";
document.getElementById("display2").innerHTML ="";
document.getElementById("display3").innerHTML ="";
document.getElementById("display4").innerHTML =""; 
document.getElementById("val1").value="";
document.getElementById("val2").value="";
document.getElementById("val1").focus();
}
</script>
</body>
<html>