Sunday, July 30, 2017

Product of Two Numbers in NodeJS

Here is a simple program that I wrote using NodeJS to accept two integer value from our user and then our program will compute the product value of two number provided by our user. The code is very short and easy to understand.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.






Sample Program Output


Program Listing


/* Product of Two Numbers in NodeJs */
/* July 30, 2017   Sunday         */
/* Written By: Mr. Jake R. Pomperada */


var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

     

console.log('\n');
console.log('Product of Two Numbers in NodeJS');
console.log('\n');
rl.question('Enter first value : ', function (x) {
   rl.question('Enter  second value : ', function (y) {
var a = parseInt(x);
var b = parseInt(y);
        var product = (a*b);
       console.log('\n');
       console.log('The product of ',a, ' and ',b, ' is ' , product,'.');
  console.log('\n');
       console.log('End of Program');
        rl.close();
    });
});



Hello World in NodeJS

A very simple program to show a message hello world using NodeJS.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.



Sample Program Output


Program Listing


/* Hello World in NodeJs */
/* July 30, 2017   Sunday          */
/* Written By: Mr. Jake R. Pomperada */
     

console.log('\n');
console.log('Hello World in NodeJS');
console.log('\n');

console.log('End of Program');

Count eight digits in PHP

A simple program that will ask the user to give a series of numbers in integer format. Our program will count the number of eight digit occurrence based on the given number by our user. The code is written in PHP as my programming language and it is very easy to understand.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.






Sample Program Output


Program Listing

<html>
  <body>
  <style>
   body {
  font-family:arial;
  font-weight:bold;
  font-size:18px;
   }
   
   #textboxid
{
font-family:arial;
font-weight:bold;
font-size:18px;
    height:25px;
    }
  </style>
  
  <?php
  $val = $_POST['value1'];
  
  if(isset($_POST['clear'])) 
$val="";
}
  ?>
   <br><br>
   <h4> Count Numbr 8 Digits in PHP </h4>
   
  <form method="post" action="">
Enter a number &nbsp;&nbsp;&nbsp;
<input id="textboxid" type="text" name="value1" value="<?php echo $val; ?>" autofocus required>
<br><br><br>
<input type="submit" name="submit" value="Ok"> &nbsp;&nbsp;&nbsp;
<input type="submit" name="clear" value="Clear">
</form>

 <?php

 function count8($num)
{
return preg_match_all("/[8]/",$num);
}

 if(isset($_POST['submit'])) 
    echo "<br><br>";
echo "The number of 8 digits is " .count8($val).".";
}

?>
 </body>
 </html>





Count Number of Eight Digits in Visual Basic 6

A simple program that will ask the user to give a series of numbers in integer format. Our program will count the number of eight digit occurrence based on the given number by our user. The code is written in Visual Basic 6 and it is very easy to understand.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.








Sample Program Output


Program Listing

Function CountChar(ByVal Text As String, ByVal Char As String) As Long
    Dim V As Variant
    V = Split(Text, Char)
    CountChar = UBound(V)
End Function


Private Sub Command1_Click()
Label1.Caption = "The Number of 8 Digits in the given number is " & CountChar(Text1.Text, "8") & "."
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Label1.Caption = ""
Text1.SetFocus
End Sub

Private Sub Command3_Click()
End
End Sub

Saturday, July 29, 2017

Count Number of Eight Digits in Visual Basic NET

A simple program that will ask the user to give a series of numbers in integer format. Our program will count the number of eight digit occurrence based on the given number by our user. The code is written in Visual Basic NET and it is very easy to understand.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.







Sample Program Output


Program Listing

Public Class Form1

    Public Function CountCharacter(ByVal value As String, ByVal ch As Char) As Integer
        Return (New System.Text.RegularExpressions.Regex(ch)).Matches(value).Count
    End Function


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Label2.Text = "Total Number of  Number of 8 Digitst is " & CountCharacter(TextBox1.Text, "8") & "."
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        End
    End Sub

    Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click

    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        TextBox1.Text = ""
        Label2.Text = ""
        TextBox1.Focus()
    End Sub
End Class


Thursday, July 27, 2017

Addition of Two Numbers in NodeJS

I started learning NodeJS programming the first thing that I would like to write is to add the two numbers using NodeJS here is the solution. The code is very simple and easy to understand for beginners like me that is new in NodeJS programming.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.






Sample Program Output


Program Listing

sum.js

/* Addition of Two Numbers in NodeJs    */
/* July 27, 2017   Thursday   10:41 PM  */
/* Written By: Mr. Jake R. Pomperada   */


var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

console.log('\n');
console.log('Addition of Two Numbers in NodeJS');
console.log('\n');
rl.question('Enter first value : ', function (x) {
   rl.question('Enter  second value : ', function (y) {
var a = parseInt(x);
var b = parseInt(y);
        var sum = (a+b);
       console.log('\n');
       console.log('The sum of ',a, ' and ',b, ' is ' , sum,'.');
  console.log('\n');
       console.log('End of Program');
        rl.close();
    });
});




Saturday, July 15, 2017

Basics of Struct in C++


In this article shows you how to use basics of struct in C++ the code is very easy to understand and use.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.





Program Listing


#include <iostream>

using namespace std;

struct new_person {
    string name;
    int age;
    int val1;
    int val2;
};

main() {

 int sum_up=0;

    new_person jake;
    new_person boy = {"Boy Abunda",65};
    new_person solve;
    solve.val1 = 5;
    solve.val2 =10;

    sum_up = (solve.val1 + solve.val2);



    cout << "\n\n";

    jake.name = "Jake Rodriguez Pomperada";
    jake.age = 31;
    cout << "\t\t Basics of Struct in C++";
    cout << "\n\n";
    cout << jake.name <<  " " << " Age " <<jake.age;
    cout << "\n\n";
    cout << boy.name <<  " " << " Age " <<boy.age;
    cout << "\n\n";
    cout << "The sum of "<< solve.val1 << " and " <<
          solve.val2 << " is " << sum_up << ".";
    cout << "\n\n";
    system("pause");
}



Using Structure in C++

A very simple program to demonstrate how to use structure in C++ the code is very easy to understand and use.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.




Program Listing

#include <iostream>

using namespace std;

struct new_person {
    string name,address;
    int age;
};

main() {
    new_person sample;

    cout << "Enter your name : ";
    getline(cin,sample.name);
    cout << "\nEnter your Address : ";
    getline(cin,sample.address);
    cout << "\nEnter your Age : ";
    cin >> sample.age;


    cout << "\n\nName    : " << sample.name;
    cout << "\n\nAddress : " << sample.address;
    cout << "\n\nAge     : " << sample.age;
    cout << "\n\n";
    system("pause");

}

Student Record System in AngularJS and PHP


In this article will show how to display and search a student record using AngularJS and PHP. The code is very easy to understand and use.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.







Sample Program Output


Program Listing

index.php


<html ng-app="fetch">
    <head>
    <title>AngularJS and PHP in AngularJS and PHP </title>
      <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
            <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.24/angular.min.js"></script>
    </head>
    <body>
    <br>
<style>
  body {
  font-family:arial;
  font-weight:bold;
  size:12px;
      background-color:lightblue; 
  
  }
 </style> 
      <div class="row">
        <div class="container">
         <h1>Student Record System in AngularJS and PHP</h1>
<br><br>
          <div ng-controller="dbCtrl">
            Type Student Name or ID Number Here 
<br><br>
<input type="text" ng-model="searchFilter" class="form-control">
<br><br>

            <table class="table table-hover">
                <thead>
                    <tr>
<th>ID</th>                       
   <th>Student Name</th>
                        <th>Course</th>
<th>Email Address</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="students in data | filter:searchFilter"> 
                        <td>{{students.student_id}}</td>
                        <td>{{students.name}}</td>
<td>{{students.course}}</td>
                        <td>{{students.email}}</td>
                    </tr> 
                </tbody>
            </table>
          </div>
        </div>
      </div>
    </body>

    <script>
        var fetch = angular.module('fetch', []);

        fetch.controller('dbCtrl', ['$scope', '$http', function ($scope, $http) {
            $http.get("ajax.php")
                .success(function(data){
                    $scope.data = data;
                })
                .error(function() {
                    $scope.data = "error in fetching data";
                });
        }]);

    </script>

    </html>


ajax.php

<?php
//database settings
$connect = mysqli_connect("localhost", "root", "", "school");

$result = mysqli_query($connect, "select * from students order  by name ASC");

$data = array();

while ($row = mysqli_fetch_array($result)) {
  $data[] = $row;
}
    print json_encode($data);

?>


students.sql

-- phpMyAdmin SQL Dump
-- version 4.6.5.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jul 12, 2017 at 11:51 AM
-- Server version: 10.1.21-MariaDB
-- PHP Version: 5.6.30

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `school`
--

-- --------------------------------------------------------

--
-- Table structure for table `students`
--

CREATE TABLE `students` (
  `id` int(11) NOT NULL,
  `student_id` varchar(20) NOT NULL,
  `name` varchar(200) NOT NULL,
  `course` varchar(200) NOT NULL,
  `email` varchar(200) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `students`
--

INSERT INTO `students` (`id`, `student_id`, `name`, `course`, `email`) VALUES
(1, '1', 'Bill Gates', 'BS Information Technology', 'bill_gates@yahoo.com.ph'),
(2, '2', 'Digong Duterte', 'BS LAW', 'digong@davao.gov.ph'),
(3, '3', 'Kobe Bryant', 'BS Managerial Accounting', 'kobe@la_lakers.com'),
(4, '4', 'Carina Tan', 'MS Information Technology', 'carina_tan@hotmail.com'),
(5, '5', 'Alma Duterte', 'MAED-IT', 'alma_duterte@lycos.com.ph'),
(6, '6', 'Baste Duterte', 'BS Marine Technology', 'baste@cnn.com.ph'),
(7, '7', 'Jake Pomperada', 'BS Computer Science', 'jakerpomperada@yahoo.com'),
(8, '8', 'Jacob Samuel Pomperada', 'BS Computer Engineering', 'jacob_samuel_pomperada@gmail.com'),
(9, '9', 'Ma. Junallie F. Pomperada,PH.D', 'BS Chemical Engineering', 'alliepomperada@yahoo.com.ph'),
(10, '10', 'Julianna Rae F. Pomperada', 'BS Business Management', 'iyapomperada@live.com');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `students`
--
ALTER TABLE `students`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `students`
--
ALTER TABLE `students`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;

/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;







Grading System in AngularJS

A very simple program that I wrote using AngularJS to compute the grade of the student. The code is very simple and easy to understand.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.




Program Listing

<html>
   <head>
      <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.5.2/angular.min.js"></script>
   </head>
   
   <body ng-app>
     Prelim Grade   <input ng-model="prelim"  type="number"> <br>
     Midterm Grade  <input ng-model="midterm" type="number"> <br>
Endterm Grade <input ng-model="endterm"  type="number"> 
<br><br>
 
Your Grade is {{ (prelim * 0.2) + (midterm * 0.3) + (endterm * 0.5) | number : 2 }}
</body>
</html>

 
  


AngularJS JSON Fetching Student Records


This sample program will fetch the record from a JSON file using angularjs. The code is very simple and easy to use. 

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.




Sample Program Output



Program Listing

index.php


<html ng-app="StudentApp">
  <head>
    <meta charset="utf-8">
    <title>AngularJS JSON Fetching Student Records</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
    <script>
      var countryApp = angular.module('StudentApp', []);
      countryApp.controller('StudentController', function ($scope, $http){
        $http.get('students.json').success(function(data) {
          $scope.records = data;
        });
      });
    </script>

<style>
h2 {
text-align:center;
color:blue;
position: relative;
top: 40px;
}

table.center {
    position: relative;
top: 60px;
width:80%; 
font-weight:bold;
    margin-left:15%; 
    margin-right:15%;
}
  </style>
  </head>
  <body ng-controller="StudentController">
<h2>AngularJS JSON Fetching Student Records</h2>
    <table class="center" border="1">
      <tr>
        <th>Student Name</th>
<th>Course</th>
        <th>Year Level</th>
<th>Address</th>
      </tr>
      <tr ng-repeat="students in records">
        <td>{{students.name}}</td>
<td>{{students.course}}</td>
        <td>{{students.year_level}}</td>
<td>{{students.address}}</td>
      </tr>
    </table>
  </body>
</html>


students.json

[
  {
    "name": "James Dean",
    "course": "BSIT",
    "year_level": "First Year",
"address": "One Gateway USA"
  },
  
  {
    "name": "Linda Lee",
    "course": "BSMA",
    "year_level": "Second Year",
"address": "#12345 Microsoft Way USA"
  },
  
  {
    "name": "Bryan Adams",
    "course": "MSIM",
    "year_level": "Third Year",
"address": "Spartan Road USA"
  },

  {
    "name": "Jake Pomperada",
    "course": "BSCS",
    "year_level": "Fourth Year",
"address": "Purok Pag-asa, Barangay Alijis, Bacolod City Negros Occidental"
  },

  {
    "name": "Jacob Samuel Pomperada",
    "course": "BSChe",
    "year_level": "Second Year",
"address": "Purok Pag-asa, Barangay Alijis, Bacolod City Negros Occidental"
  }

  

]