Saturday, July 30, 2016

Ternary Operator in C++

Here is a sample program that I wrote in C++ to show how to use ternary 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>

 using namespace std;

main() {
  for(;;) {
    int number=0,value=0;

    system("cls");
    cout << "Enter a Number :=> ";
    cin >> number;

    if (number==0) {
         cout << "\n\n";
         cout << "\t Thank You For Using This Program";
         break;
     }
      value = (number >=10 ? 20:10);

      cout << "\n\n";
      cout << "The resulting value is "
           << value << ".";
     cout << "\n\n";
     system("pause");

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


Factorial Using Pointers in C++

A simple program that I wrote for my programming class before in college factorial program using pointers in C++. What does the program will do is to ask the user to give a number and then our program will compute its factorial 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


#include <iostream>

using namespace std;

int factorial (int num)
{
 if (num==1)
  return 1;
 return factorial(num-1)*num;
}

main() {
    int value=0;
    int *p;
    cout << "\t Recursion using Pointers";
    cout << "\n\n";
    cout << "Enter a Number :=> ";
    cin >> value;
    p = &value;
    cout << "\n";
    cout <<"The factorial value of " << value
        << " is " << factorial(value) << ".";
    cout << "\n\n";
    system("pause");
}

Array in Turbo Pascal

Here is a sample program that I wrote using Pascal to accept five numbers from the user and then display the numbers given by the user using Array as my data structure in Pascal. 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.




Sample Program Output


Program Listing

Program List_Values;
Uses Crt;

Type
  values = array[1..5] of integer;

Var item : values;
    a: integer;
Begin
  clrscr;
  For a := 1 to 5 Do
  Begin
    Write('Enter value in item no. ' ,a,':');
    readln(item[a]);
  End;
   Writeln;
   Writeln;
   Write('List of Values You Given');
   Writeln;
   For a := 1 to 5 Do
   Begin
     writeln(item[a]);
   End;
   Readln;
End.




Moving Text in Turbo Pascal

Here is a sample program that I wrote about 15 years ago in Pascal using Turbo Pascal 5.0 as my Pascal compiler to make the text moving back and forth in the screen. It's a kind of simple animation using CRT library in Turbo Pascal For DOS.

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

Program Animation;
Uses Crt;
Var A,B : Integer;
    St1,St2 : String;
    Ch : Char;
Begin
 Repeat
 Clrscr;
 St1 := 'Jose';
 St2 := 'Maria';
  Textcolor(Green);
  Gotoxy(36,12);
  Write(Chr(03));
  Normvideo;
   For A := 1 to 29 DO
   Begin
   Textcolor(LightRed);
   Gotoxy(A,12);
   Write(' ',St1);
   Delay(1200);
  Normvideo;
   end;
    For b := 76 downto 37 DO
   begin
   Textcolor(LightBlue);
   Gotoxy(b,12);
   Write(St2,' ');
   Delay(3700);
  Normvideo;
  End;
  until ch = #13;
  Readln;
  End.

Addition of Two Numbers in Turbo Pascal

Here is a simple program that I wrote maybe 16 years ago in Pascal using Turbo Pascal 5.0 for DOS as my Pascal compiler. The program will ask the user to give to integer number and then it will compute the sum of the two numbers. 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

Program Addition_Two_Numbers;
Uses Crt;

Var A,B  : Integer;
    Ch   : Char;

Function Add(Var C,D : Integer) : integer;
Begin
 Add := C + D;
End;

Begin
 Repeat
 Clrscr;
 Write('Enter the First Value :');
 Readln(A);
 Write('Enter the First Value :');
 Readln(B);
 Writeln;
 Write('The sum of two values is',' ',Add(A,B));
 Writeln;
 Writeln;
 Repeat
 Write('Do You Want To Continue y/n ? ');
 Ch := Upcase(Readkey);
 Until Ch in ['Y','N'];
 Clrscr;
 Until Ch = 'N';
 Exit;
 Readln;
End.

Animation in Turbo Pascal

In this article I would like to share with you a sample animation program that I wrote in Turbo Pascal  a long time ago that uses basic delay, text color and gotoxy coordinate using the Turbo Pascal Crt library.

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

Program Hellos;
Uses Crt;
Var A,B,C,D,E : integer;
    St : String;
    Ch : Char;
Begin
 Repeat
 TextAttr := LightCyan;
 Clrscr;
 St := 'Hello';
 For A := 1 to 75 DO
  Begin
    Gotoxy(A,1);
    Write(' ',St);
    Delay(1830);
   End;
      For b := 1 to 24 DO
  Begin
    Delline;
    Gotoxy(75,b);
    Write(St);
    Delay(1830);
   End;
    For C := 75 Downto 1 DO
  Begin
    Gotoxy(C,24);
    Write(St,' ');
    Delay(1830);
   End;
     For D := 24 Downto 1 DO
  Begin
    Delline;
    Gotoxy(1,d);
    Write(St);
    Delay(1830);
  end;
 Until Ch = #13;
 End.

Menu Program in Pascal

In this article I would like to share with you a sample program in Pascal how to create a menu program which allows the user to select an option in the screen. I am using Turbo Pascal 5.0 as my compiler in this program. I hope you will find my program useful. Thank you.

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

Program Menu;
Uses Crt;
Var 
   Option : Integer;
Begin
Repeat
Clrscr;
Writeln('======== MENU PROGRAM IN PASCAL ======');
Writeln;
Writeln('[1] Add Record');
Writeln('[2] Modify Record');
Writeln('[3] Delete Record');
Writeln('[4] View Record');
        Writeln('[5] Quit Program');
        Writeln;
        Writeln('Enter Selection');
         Readln(Option);
Until (Option < 1) AND (Option > 5);
Readln;
End.


Friday, July 29, 2016

Positive and Negative Number Checker in Rust

In this article I would like to share with you a sample program that will ask the user to give an integer number and then our program will check whether the given number by our user is positive or negative number using Rust 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.



Sample Program Output


Program Listing

// Positive and Negative Number Checker in Rust Programming language.
// Written By: Mr. Jake R. Pomperada, MAED-IT
// July 28, 2016

use std::io::{self, Write};
use std::fmt::Display;
use std::process;

fn main() {
       println!("\n");
       println!("\tPositve and Negative Number Checker in Rust");
       println!("\n");

    let number_value: i32 = grab_input("Enter a Number ")
        .unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)))
        .trim()
        .parse()
        .unwrap_or_else(|e| exit_err(&e, 2));

   if number_value >= 0 {
    println!("\n"); 
    println!("The number {} is a POSITIVE NUMBER.",number_value);
  }
 else {
    println!("\n");
    println!("The number {} is a NEGATIVE NUMBER.",number_value);
   }

    println!("\n"); 
    println!("End of Program");
}

fn grab_input(msg: &str) -> io::Result<String> {
    let mut buf = String::new();
    print!("{}: ", msg);
    try!(io::stdout().flush());

    try!(io::stdin().read_line(&mut buf));
    Ok(buf)
}

fn exit_err<T: Display>(msg: T, code: i32) -> ! {
    let _ = writeln!(&mut io::stderr(), "Error: {}", msg);
    process::exit(code)
}


Admin Dashboard in PHP and MySQL

In this article I would like to share with you a sample program wrote by a good friend of mine Mr. Dave Marcellana he share his work to us in order to help our fellow software developer in PHP and MySQL. He called this program admin dashboard in PHP and MySQL using Bootstrap framework that manages user accounts it demonstrate the use of CRUD application in managing records.

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



Product Cost Program in Rust

A program that I wrote using Rust programming language that will ask the user the cost of the product and its quantity after which it will compute its total cost. The code is very simple and intended for beginners in Rust programming.

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

// Product Cost Program in Rust Programming language.
// Written By: Mr. Jake R. Pomperada, MAED-IT
// July 28, 2016

use std::io::{self, Write};
use std::fmt::Display;
use std::process;


fn main() {
       println!("\n");
       println!("\tProduct Cost Program in Rust");
       println!("\n");

    let price: f32 = grab_input("Enter the price of the item ")
        .unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)))
        .trim()
        .parse()
        .unwrap_or_else(|e| exit_err(&e, 2));


    let quantity: f32 = grab_input("Enter the quantity of the item  ")
        .unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)))
        .trim()
        .parse()
        .unwrap_or_else(|e| exit_err(&e, 2));

     let  solve_cost = price * quantity;
              
    println!("\n"); 
    println!("The total cost of the product is  $ {:.2}.",solve_cost);
    println!("\n");  
    println!("End of Program");
}



fn grab_input(msg: &str) -> io::Result<String> {
    let mut buf = String::new();
    print!("{}: ", msg);
    try!(io::stdout().flush());

    try!(io::stdin().read_line(&mut buf));
    Ok(buf)
}

fn exit_err<T: Display>(msg: T, code: i32) -> ! {
    let _ = writeln!(&mut io::stderr(), "Error: {}", msg);
    process::exit(code)
}




Year Level Checker in Rust

A simple program that I wrote using Rust programming language that will ask the user what is its year level and then our program will determine whether the user is freshmen, sophomore, junior or senior. 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.





Sample Program Output



Program Listing


// Year Level Checker in Rust Programming language.
// Written By: Mr. Jake R. Pomperada, MAED-IT
// July 28, 2016

use std::io::{self, Write};
use std::fmt::Display;
use std::process;
 
fn main() {
       println!("\n");
       println!("\tYear Level Checker in Rust");
       println!("\n");
 
    let year: i32 = grab_input("Enter the Year Level of the Student  ")
        .unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)))
        .trim()
        .parse()
        .unwrap_or_else(|e| exit_err(&e, 2));

   if year == 1 {
    println!("\n"); 
    println!("You are belong to Freshmen.");
  }
  else if year == 2 {
    println!("\n"); 
    println!("You are belong to Sophomore.");
else if year == 3 {
    println!("\n"); 
    println!("You are belong to Juniors.");
else if year == 4 {
    println!("\n"); 
    println!("You are belong to Seniors.");
else {
    println!("\n");
    println!("Sorry Invalid Year Level !!! Try again.");
   }
 
    println!("\n"); 
    println!("End of Program");
}
 
fn grab_input(msg: &str) -> io::Result<String> {
    let mut buf = String::new();
    print!("{}: ", msg);
    try!(io::stdout().flush());
 
    try!(io::stdin().read_line(&mut buf));
    Ok(buf)
}
 
fn exit_err<T: Display>(msg: T, code: i32) -> ! {
    let _ = writeln!(&mut io::stderr(), "Error: {}", msg);
    process::exit(code)
}


Circle Calculator in PHP

In this article I would like to share with you a sample program that I wrote in PHP I called this program Circle Calculator. What does the program will do is to ask the user to give the radius of the circle and then our program will compute the area and circumference of the circle. The code is very easy to understand and use. I hope you will find my work useful thank you.


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-size: 20;
    font-family:sans-serif;
    font-weight: bold;
  }
input {
    font-size: 20px;
    font-weight: bold;
   }

  /* http://cssdemos.tupence.co.uk/button-styling.htm */ 
  input#shiny {
padding: 4px 20px;
/*give the background a gradient*/
background:#ffae00; /*fallback for browsers that don't support gradients*/
background: -webkit-linear-gradient(top, blue,blue);
background: -moz-linear-gradient(top, blue, blue);
background: -o-linear-gradient(top, blue, blue);
background: linear-gradient(top, blue, blue);
border:2px outset #dad9d8;
/*style the text*/
font-family:Andika, Arial, sans-serif; /*Andkia is available at http://www.google.com/webfonts/specimen/Andika*/
font-size:1.1em;
letter-spacing:0.05em;
text-transform:uppercase;
color:#fff;
text-shadow: 0px 1px 10px #000;
/*add to small curve to the corners of the button*/
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
/*give the button a drop shadow*/
-webkit-box-shadow: rgba(0, 0, 0, .55) 0 1px 6px;
-moz-box-shadow: rgba(0, 0, 0, .55) 0 1px 6px;
box-shadow: rgba(0, 0, 0, .55) 0 1px 6px;
}
/****NOW STYLE THE BUTTON'S HOVER STATE***/
input#shiny:hover, input#shiny:focus {
border:2px solid #dad9d8;
}
 </style>
<body>
  <?php
  $values = $_POST['inputText'];


  if(isset($_POST['ClearButton'])){
  $values = "";

  }

   ?>
  <br>
  <h4> Circle Calculator </h4>
  <form action="" method="post">
  What is the Radius of the Circle?
  <input type="text" name="inputText" size="5" maxlength="5"
  value="<?php echo $values; ?>"  style="width:100px; height:30px;" required autofocus=""/>
  <br><br>
  <input id="shiny" type="submit" value="Ok" name="SubmitButton"/>
  &nbsp;&nbsp;&nbsp;
  <input id="shiny" type="submit" value="Clear" name="ClearButton"/>
</form>
<?php

$values = $_POST['inputText'];
if(isset($_POST['SubmitButton'])){

$r = (int)$values;
$p=3.14159;

$Area= $p*pow($r,2);
$Circumference=$p*$r*2;
$Diameter= 2*$r;

echo "<br>";
echo "The Area of Circle is : ".number_format($Area,2,'.','')."m";
$str = "&sup2;";
echo $str;
echo "<br>";
echo "The Diameter of Circle is : ".number_format($Diameter,2,'.','');
echo "<br>";
echo "Circumference of Circle is : ".number_format($Circumference, 2, '.', '')."m";

}
?>

</body>
</html>






Sunday, July 24, 2016

Payroll Program in Turbo Pascal

In this article I would like to share with you a sample program that I wrote using Pascal as my language of choice. I called this program Payroll Program in Turbo Pascal. What does the program will do is to ask the user the name of the employee and then it will ask the number of days work. After which the program will compute the salary of the employee. I am using Turbo Pascal 6 For DOS as my compiler in writing this program.

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

Program Payroll;
Uses Crt;

Const rate = 5.50;

Var  employee : string;
     days     : integer;
     total    : real;

Begin

Clrscr;
Writeln('Payroll Program in Pascal');
Writeln;
Write('Give Employees Name :');
Readln(employee);
Write('Give Number of Days Worked : ');
Readln(days);

Total := (days * rate);

    Writeln;
Write('Display Payroll Result');
Writeln;
        Writeln;
        Write('Employees Name : ' ,employee);
        Writeln;
Write('For ',days:2, ' days of work, you have earned $');
Write(total:5:2);
Writeln;
    Writeln;
Write('End of Program');
Readln;
End.