Friday, August 5, 2016

Grade Brackets in C++

In this article  I would like to share with you a sample program that I wrote for my class in C++ programming 6 years ago to check and determine the grade brackets of the students using two dimensional array in C++. The code is very simple and easy to understand I hope you will find my work useful in learning C++ 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

#include <iostream>

using namespace std;

 main()
{
    double grades[5][2];
    int row=0,col=0, count=0, count2=0;
    int count3=0, count4=0;
    cout << "\t Grade Bracket Version 1.0 ";
    cout << "\n\n";
    // Ask for 10 grades
    for(row= 0 ; row < 5 ; row++){
     for (col=0; col <2; col++) {
       cout<< "Enter grades :=>";
       cin >> grades[row][col];
    }
    }
   for(row= 0 ; row < 5 ; row++){
     for (col=0; col <2; col++) {
      if(grades[row][col] >= 90){
         count++;
      }
      if(grades[row][col] >= 80 && grades[row][col] <90)
       {
        count2++;
       }
    if(grades[row][col] >= 75 && grades[row][col] < 80)
       {
        count3++;
       }
   if(grades[row][col] < 75)
      {
       count4++;
      }
    }
   }
    //display
    cout << "\n====================";
    cout << "\n     RESULTS        ";
    cout << "\n====================";
    cout << "\n\n";
    cout<<"\nGrades >=90    is: " <<count;
    cout<<"\nGrades 80 - 89 is: " <<count2;
    cout<<"\nGrades 75 - 80 is: " <<count3;
    cout<<"\nGrades < 75    is: " <<count4;
    cout << "\n\n";
    system("pause");

}










Days of the Week in PHP

In this article I would like to give you a sample program that will ask the user to give the year, month and day and then our program will determine what is the day in that given date using PHP. 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

<html>
<title>Days of the Week in PHP</title>
<style>
  body {
   font-family: arial;
   font-size: 18px;
   font-weight: bold;
 };
</style>
<body>
  <?php
   error_reporting(0);
  $input_A = $_POST['inputYear'];
  $input_B = $_POST['inputMonth'];
  $input_C = $_POST['inputDay'];
  if(isset($_POST['ClearButton'])){
  $input_A="";
  $input_B="";
  $input_C="";
  $display_result="";
  }

   ?>
   <br>
  <h2>Days of the Week in PHP</h2>
<form action="" method="post">
  What is the year?
  <input type="text" name="inputYear"
  value="<?php echo $input_A; ?>" size="5" autofocus required/>
<br><br>
  What is the month?
  <input type="text" name="inputMonth"
  value="<?php echo $input_B; ?>" size="5" required/>
  <br><br>
  What is the day?
  <input type="text" name="inputDay"
  value="<?php echo $input_C; ?>" size="5" required/>
  <br><br>
  <input type="submit" name="SubmitButton" value="Ok"/>
   &nbsp;&nbsp;&nbsp;
  <input type="submit" name="ClearButton" value="Clear"/>
</form>
<?php
function dateName($date) {

       $result = "";
       $convert_date = strtotime($date);
       $month = date('F',$convert_date);
       $year = date('Y',$convert_date);
       $name_day = date('l',$convert_date);
       $day = date('j',$convert_date);
       $result = $name_day;

       return $result;
   }


if(isset($_POST['SubmitButton'])){

  $dateValue = $input_A.$input_B.$input_C;
  $day1 = dateName($dateValue);
  echo "<br>";
  $display_result = "The day is ".$day1.".";
  echo $display_result;
  echo "<br>";
 }

?>
</body>
</html>


Greatest Common Divisor in PHP

Hi there in this article I would like to share with you a program that I wrote in PHP to compute for the Greatest Common Divisor. What does our program will do is to ask the user to give two numbers and then it will compute it greatest common divisor 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


<html>
<title>  Greatest Common Divisor Solver in PHP  </title>
<style>
  body {
   font-family: arial;
   font-size: 18px;
   font-weight: bold;
 };
</style>
<body>
  <?php
   error_reporting(0);
  $input_A = $_POST['inputFirst'];
  $input_B = $_POST['inputSecond'];
  if(isset($_POST['ClearButton'])){
  $input_A="";
  $input_B="";
  $display_result="";
  }

   ?>
   <br>
  <h2> Greatest Common Divisor Solver in PHP </h2>
<form action="" method="post">
  Give first number
  <input type="text" name="inputFirst"
  value="<?php echo $input_A; ?>" size="5" autofocus required/>
<br><br>
  Give second number
  <input type="text" name="inputSecond"
  value="<?php echo $input_B; ?>" size="5" required/>
  <br><br>

  <input type="submit" name="SubmitButton" value="Ok"/>
   &nbsp;&nbsp;&nbsp;
  <input type="submit" name="ClearButton" value="Clear"/>
</form>
<?php


function GCD($a, $b)
{
if ($a == 0)
return $b;

while ($b != 0)
{
if ($a > $b)
$a -= $b;
else
$b -= $a;
}

return $a;
}


if(isset($_POST['SubmitButton'])){

$value = GCD($input_A,$input_B);

  echo "<br>";
  $display_result = "The Greatest Common Divisor between "
                    .$input_A. " and  ".$input_B. " is "
                    .$value.".";

  echo $display_result;
  echo "<br>";
 }

?>
</body>
</html>



Saturday, July 30, 2016

Pass or Fail Grade Checker Using Ternary Operator in C++

Here is a sample program that I wrote in C++ to check if the given grade of the student is pass or failed using ternary operator in C++.

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() {

    int grade=0;

    cout << " Conditional Operator Demo (?:) ";
    cout << "\n\n";
    cout << "Enter your grade : ";
    cin >> grade;
    cout << "\n\n";
    cout << (grade >= 75 ? "You Passed." : "You Failed.");
    cout << "\n\n";
     if (grade >= 75) {
         cout << "You Passed.";
     }
     else {
         cout << "You Failed.";
     }
    cout << "\n\n";
    system("pause");
}

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