Saturday, February 27, 2016

Highest and Slowest Number Finder in Python

This sample program will ask the user to give a series of number and then our program will determine which of the given number is the highest and the lowest using Python as my programming language.  The code is very simple and easy to understand. In order to stop running the program the user can simply type the keyword "ok".

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

My mobile number here in the Philippines is 09173084360.



Sample Program Output

Program Listing

lowest = None
highest = None
print("\n")
print("FIND THE HIGHEST AND LOWEST NUMBER IN PYTHON")
print '\n'
while True:     
        number = input('Please enter a number, or "ok" to stop: ' )
        if number in ["OK", "ok"]:
              break
        try:
            num = float(number)
            if (lowest) is None or (num < lowest):
                lowest = num
            if (highest) is None or (num > highest):
                highest = num
        except ValueError:
            print("Non numeric data was entered.")
        except:
            print("Error with input...")
print '\n'
print 'The Highest Number is ' ,highest,'.'
print 'The Lowest  Number is ' , lowest,'.'
print '\n'
print("END OF PROGRAM")




Find the Highest and Lowest Number in Pascal Version 2

This simple program will ask the user to give five numbers and then our program will check and determine which of the five number is the highest and lowest number. I used Pascal programming language in writing this program, my compiler is Turbo Pascal 5.0 for DOS. This is the version two of my program in Pascal.

I hope you will find my work useful in learning programming in Pascal.

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

My mobile number here in the Philippines is 09173084360.



Sample Program Output

Program Listing

Program Highest_Lowest_Number;
Uses Crt;

Type
   Number_Array = Array[1..5] of Integer;

Var N : Number_Array;
    I, Highest, Lowest : Integer;

Begin
  Clrscr;

  I :=0;
  Highest := 0;
  Lowest :=0;

  Writeln('Find the Highest and Lowest Number');
  Writeln;

   For I := 1 to 5 Do
   Begin
    Write('Please Enter Item No. ',I,':');
    Readln(N[I]);
   End;

   For I := 1 to 5 Do
   Begin
     If (Highest<N[I]) Then
        Begin
          Highest := N[I];
        End;

      If (Lowest>N[I]) Then
        Begin
          Lowest := N[I];
        End;
    End;

   Writeln;
   Write('List of Numbers');
   Writeln;
   For I := 1 to 5 Do
   Begin
     Write(' ',N[I],' ');

   End;

   Writeln;
   Writeln;
   Write('Display Result');
   Writeln; Writeln;
   Writeln('The Highest Number is ',Highest,'.');
   Writeln('The Lowest Number is ',Lowest,'.');
   Writeln;
   Write('End of the Program');
   Readln;
End.

Sunday, February 21, 2016

Count Number of Words in a Sentence in Python

A sample program that I wrote using Python programming language that will count the number of words in a given sentence by the user. The code is very short and very easy to understand. I hope you will find my work useful in learning Python programming.

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

My mobile number here in the Philippines is 09173084360.


Program Listing

import re

def wordcounter(words):
    list = re.findall("(\S+)", words)
    return len(list)

print("\n");
print("\t Word Counter in Python");
print("\n");
str = input('Give a sentence : ')
print("\n");
print("Total Numbers of Words is",wordcounter(str),'.')
print("\n");
print("End of Program")
print("\n");

Saturday, February 20, 2016

Loan Interest Solver in C++

A simple program that I wrote to compute the loan amount using C++.


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


My mobile number here in the Philippines is 09173084360.

Program Listing

#include <iostream>
#include <iomanip>
#include <fstream>


using namespace std;

main() {

    string name;

    int principal=0;
    int number_months=0;
    float rate=0.00,solve_rate=0.00;

    ofstream file("report.txt");

    cout << "\t  Kwarta Agad Lending Investor";
    cout << "\n\n";
    cout << "Enter Customer Name    :=> ";
    getline(cin,name);
    cout << "\nEnter Amount  Loan   :=> ";
    cin >> principal;
    cout << "\nNumber of Months    :=> ";
    cin >> number_months;
    cout << "\nEnter Rate Per Month :=> ";
    cin >> rate;
    solve_rate = (principal * number_months * rate ) ;
    cout << "\n\n";
    cout << fixed << setprecision(2);
    cout << "The Simple Interest Rate is Php "
         << solve_rate << ".";

    file << "\n\t ======= Kwarta Agad Lending Investor =========";
    file << "\n\n";
    file << "\n\t\t CUSTOMER REPORT";
    file << "\n\n";
    file << "\n Customer Name     : " << name;
    file << "\n Amount   Loan     : " << principal;
    file << "\n Number of Months  : " << number_months;
    file << "\n Rate Per Month    : " << rate;
    file << "\n\n";
    file << fixed << setprecision(2);
    file << "\n Interest Rate is Php " << solve_rate;
    file.close();
    cout << "\n\n";
    system("pause");
}

Sunday, February 14, 2016

Highest and Lowest Number in Pascal

This simple program will check which of the ten numbers in an array is the highest and the lowest using Pascal as our programming language. I am using Turbo Pascal 5.0 as my Pascal compiler in this sample program.

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

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

program high_low;

uses crt;

var
  numbers:array[1..10] of integer;
  high:integer;
  low:integer;
  x:integer;


procedure quit;
begin
  writeln;
  writeln;
  writeln('Press <Enter> to Quit');
  readln;
end;

begin
  clrscr;
  numbers[1]:=2;
  numbers[2]:=3;
  numbers[3]:=-34;
  numbers[4]:=23;
  numbers[5]:=6;
  numbers[6]:=-345;
  numbers[7]:=7;
  numbers[8]:=9;
  numbers[9]:=10;
  numbers[10]:=123;

  writeln('Highest and Lowest Number Checker in Pascal');
  writeln;


  high := numbers[1];
  low := numbers[1];

  for x := 1 to 10 do
  begin
    if numbers[x] > high then
       high := numbers[x];

    if numbers[x] < low then
       low := numbers[x];
  end;

  writeln('The Highest Number: ', high);
  writeln('The Lowest Number: ', low);
  quit;
  End.



Area of a Circle in Pascal

A simple program that I wrote in Pascal that will compute the area of the circle based on the given value by the user. In this program I wrote using Turbo Pascal 5.0 as my Pascal compiler.

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

My mobile number here in the Philippines is 09173084360.



Sample Program Output

Program Listing

Program Area_Circle;
Uses Crt;

Const
  Pi = 3.1416;

Var
  Radius : Integer;
  Area    : Real;


Begin
  Clrscr;
  Writeln('Area of a Circle Solver');
  Writeln;
  Write('Enter the Radius of the Circle : ');
  Readln(Radius);

  Area := (Pi * Radius * Radius);

  Writeln;
  Writeln('The Area of the Circle is ' ,Area:8:2,'.');
  Writeln;
  Writeln('Thank You For Using This Program');
  Readln;
End.

Odd and Even Number Checker in Pascal

A simple program that I wrote using Pascal as my programming language that will ask the user to give a  number and then our program will determine if the given number by the user is ODD or EVEN number. The program itself is very short and easy to understand. I am using Turbo Pascal 6 as my compiler in writing this program.

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

My mobile number here in the Philippines is 09173084360.



Sample Program Output

Program Listing

Program Odd_Even_Number;
Uses Crt;

Var Number : Integer;
    R     : Integer;
    Ch    : Char;

Begin
  Clrscr;
  Repeat
  Writeln;
  Number := 0;
  R := 0;
  Writeln('Odd and Even Number Checker in Pascal');
  Writeln;
  Writeln;
  Write('Enter a Number : ');
  Readln(Number);

  R := Number MOD 2;

     If (R=0) Then
       Begin
         Writeln(Number ,' is a Even Number. ');
         Writeln;
       End
     Else
       Begin
         Writeln(Number,' is Odd Number. ');
         Writeln;
       End;
    Writeln;
    Write(' Do you want to continue y/n ?');
    Ch := Upcase(readkey);
    Until Ch = 'N';
    Writeln;
    Writeln;
    Write('Thank You For Using This Software.');
    Readln;                                  
 End.



Palindrome Program in Pascal


A simple program that I wrote before in Pascal to check if the word given by the user is a Palindrome or not a Palindrome. The code is very simple and easy to understand.


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

My mobile number here in the Philippines is 09173084360.




Program Listing


Program Palindrome;
Uses Crt;
Label Finish;
VAR
StrIn, dForward, Reversed:String;
n:Integer;
ch:Char;
Palin:Boolean;
Begin
     Clrscr;
     Writeln; Writeln; Writeln;
     Write('              PALINDROME PROGRAM IN PASCAL        ');
     Writeln(' Just Press Enter to quit the Program');
     Repeat
           Writeln;
           Write('Enter a Word :==> ');
           Readln(StrIn);
           If StrIn = '' Then Goto Finis;
           dForward := '';  Reversed := '';
               For n := 1 to Length(StrIn) Do
           Begin
                ch := UpCase(StrIn[n]);
                If ch in ['A'..'Z'] Then
                Begin
                     dForward := dForward + ch;
                     Reversed := ch + Reversed
                End;
           End;
           Palin := dForward = Reversed;  
           If Palin then Writeln('"',StrIn, '" is a palindrome.') 
           Else Writeln('"',StrIn, '" is not a palindrome.'); 
Finish: 
     Until StrIn = ''; 
END.

Positive and Negative Number Checker in Pascal

Here is a sample program that I wrote using Pascal as my programming language that will ask the user to give a number and then our program will check whether the give number of the user is a positive or negative number after which our program will ask the user if the user will continue using the program or not.  This program that I wrote is very simple it brings back the memories during my college day's when I am taking up Pascal programming I am using Turbo Pascal 6.0 as my Pascal compiler in this program.

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

My mobile number here in the Philippines is 09173084360.


Sample Program Output


Program Listing

Program Positive_and_Negative_Numbers;
Uses Crt;

Var Number : Integer;
    Ch     : Char;

Begin
  Clrscr;
  Repeat
  Writeln;
  Number := 0;
  Writeln('Positive and Negative Number Checker in Pascal');
  Writeln;
  Writeln;
  Write('Enter a Number : ');
  Readln(Number);

     If (Number >=0) Then
       Begin
         Writeln(Number ,' is a Positive Number. ');
         Writeln;
       End
     Else
       Begin
         Writeln(Number,' is a Negative Number. ');
         Writeln;
       End;
    Writeln;
    Write(' Do you want to continue y/n ?');
    Ch := Upcase(readkey);
    Until Ch = 'N';
    Writeln;
    Writeln;
    Write('Thank You For Using This Software.');
    Readln;                                  
 End.


Average of Ten Numbers Using Array in Turbo Pascal 6.0

Pascal programming language is the first programming language that I have learned during my first years and second year in college taking up my course in Bachelor of Science in Computer Science in the University of Negros Occidental - Recoletos, Bacolod City, Philippines. 

I find this programming language very easy to learn primary reason is that it uses commonly used english words and terms very near to user understand indeed. I learned many things in Pascal that I was able to used it in learning other programming language such as C, C++, BASIC and among others.

In this sample program that I wrote using Pascal as my programming language and Turbo Pascal 6.0 as my Pascal compiler. This program will ask the user to give ten numbers and then our program will find the average of the ten number being provided by the user using one dimensional array in Pascal.

The program itself is very easy to understand and very useful for those who wants to learn Pascal programming. I know now a day's programming in Pascal is not popular compared to the past 20 years. I just try my best to share the things that I learned before in Pascal programming.


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

My mobile number here in the Philippines is 09173084360.



Sample Program Output



Program Listing


Program Average_Ten_Numbers;
Uses Crt;
Var
  NumberArray : Array[1..10] of Integer;
  Average : Real;
  i : integer;

Begin
  Clrscr;
  Gotoxy(24,2);
  Writeln('Average of Ten Numbers in Pascal');
  Writeln;

  For i :=  1 To 10 Do
    Begin
      Write('Enter Item No. ' ,i, ' : ');
      Readln(NumberArray[i]);
    End;

  Average := 0;
  i := 1;

  Repeat
    Average := Average + NumberArray[i];
    i := i + 1;
  Until i > 10;

  Average := Average / 10;
  Writeln;
  Writeln('The average is : ',Average:0:2);
  Writeln;
  Writeln(' Thank you for using This Software');
  Readln;
End.




Sunday, February 7, 2016

Kilograms To Pounds Converter in Python


A simple program that I wrote in Python as my programming language that will ask the user to give how many kilograms and then it will convert it to pounds equivalent. The code is very simple I intended my work for beginners like me in Python programming.

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

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

import math

print('\n')
print('\t Kilograms To Pounds in Python')
print('\n')

kilograms = input('How many kilograms : ')

solve_pounds = (kilograms * 2.20462262 )

print('\n')
print('The {0} Kilogram(s) is equivalent to {1} Pound(s). '.format(kilograms,round(solve_pounds,2)))
print('\n')
print('Thank you for using this program')