Saturday, April 9, 2016

Decimal To Hexadecimal in Python


A simple program that I wrote using Python programming language that will ask the user to give decimal number and then our program will convert the given number into its hexadecimal 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("DECIMAL TO HEXADECIMAL CONVERTER")
   print()
   decimal = int(input("Enter a Number: "))
   print()
   print('The number {0} in Decimal is equivalent to '.format(decimal))
   print(hex(decimal), " in Hexadecimal.");
   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()


Decimal To Octal Converter in Python

A simple program that I wrote using Python programming language that will ask the user to give decimal number and then our program will convert the given number into its octal 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("DECIMAL TO OCTAL CONVERTER")
   print()
   decimal = int(input("Enter a Number: "))
   print()
   print('The number {0} in Decimal is equivalent to '.format(decimal))
   print(oct(decimal), " in octal.");
   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()



Decimal To Binary Converter in Python

A simple program that I wrote using Python programming language that will ask the user to give decimal number and then our program will convert the given number into its binary 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 convert_binary(values):
   
   if values > 1:
     convert_binary(values//2)
   print(values % 2,end = '')

def my_program():
   print()
   print("DECIMAL TO BINARY CONVERTER")
   print()
   decimal = int(input("Enter a Number: "))
   print()
   print('The number {0} in Decimal is equivalent to '.format(decimal))
   convert_binary(decimal);
   print(" in binary.");
   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()


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