Tuesday, March 17, 2015

Count Years or Weeks in a given days in C++

In this article I would like to share with you a sample program that I wrote using C++ I called this program Count Years or Weeks  in a given days Using C++. The code is very simple by the use of simple formulas I hope you will find my work useful in your programming assignments and projects in C++.

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

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360



Program Lisitng

#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{

 int years=0,days=0,weeks=0,solve=0;
 char reply;
 do {
 system("cls");
 cout << "\n==================================================";
 cout << "\n||  COUNT NO. OF YEARS OR WEEK IN A GIVEN DAY   ||";
 cout << "\n==================================================";
 cout << "\n\n";
 cout<<"ENTER NUMBER OF DAYS :=> ";
 cin>>days;
 years = days/365;
 solve=days-(years*365);
 weeks=days/7;
 solve=days-(weeks*7);

  cout << "\n\n";
  cout << "\n=========================";
  cout << "\n||  DISPLAY RESULTS    ||";
  cout << "\n=========================";
  cout << "\n\n";
  cout<<years << " Year(s) or " << weeks << " Week(s).";
  cout << "\n\n";
  cout << "Do you want to continue y/n :=> ";
  cin >> reply;
 } while (toupper(reply)=='Y');
  cout << "\n\n";
  cout << "======  THANK YOU FOR USING THIS PROGRAM =====";
  cout << "\n\n";
}


DOWNLOAD SOURCE CODE HERE



Monday, March 16, 2015

Occurrence of the Word Program in Java

In this short article I would like to share with you a sample program that I called Occurrence of the Word Program in Java. What does the program will do is to allow the user to enter a sentence that has a repetitive words and then our program will ask the user what word to be search and count its number of occurrence and then our program will count the number of times a certain word appears in a given sentence by our user.

If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360




Program Listing

import java.util.Scanner;

class count_words {


public static int find_words(String string, String substr) {
    int a=0;
    int second_string = 0;
    int count = 0;
    do {
        a = string.indexOf(substr,second_string);
        if (a != -1) count++;
        second_string = a+substr.length();
    } while(a != -1);
    return count;
}

public static void main (String[] args ){

           Scanner in = new Scanner(System.in);
           String str1,str2,str3,str4;

           System.out.println("==============================================");
           System.out.println("||      OCCURENCE OF THE WORD PROGRAM       ||");
           System.out.println("==============================================");
           System.out.print("\n");
        System.out.println("Enter a Sentence      :   ");
        System.out.print("\n");
           str1 = in.nextLine();
           str3 = str1.toUpperCase();
           System.out.print("\n");
           System.out.print("Enter a word to count : ");
           str2 = in.nextLine();
           str4 = str2.toUpperCase();
           System.out.println("\n");
           System.out.println("The number of occurrence in the word : " + str4 + " is "
                             + find_words(str3,str4 ) + ".");
           System.out.println("\n");
 }
}


Saturday, March 14, 2015

Simple Multiplication Table in C++

Here a simple multiplication table in C++ that I wrote a very long time ago using for loop statements and built in library in C++. I hope beginners in C++ programming find my work useful and beneficial in their school assignments and projects.

If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360




Sample Program Output 

Program Listing

#include <cstdlib>
#include <iostream>
#include <iomanip>

using namespace std;

int main(int argc, char *argv[])
{
    int values[10] = {1,2,3,4,5,6,7,8,9,10};
    int values2[10] = {10,9,8,7,6,5,4,3,2,1};

     cout << "\n\n";
     cout << " ===== SIMPLE MULTIPLICATION TABLE =====";
     cout << "\n\n Created By: Mr. Jake R.Pomperada,MAED-IT";
     cout << "\n\n";

    for (int list=0; list <10 ; list++) {
        cout << "\n";
        cout<< setw(2) << list[values] << " x " <<
             setw(2) << list[values] << " = " <<
             setw(2) << list[values] * list[values];


        cout<< setw(10) << list[values] << " + "  <<
             setw(2) << list[values2] << " = " <<
             setw(1) << (list[values] + list[values2]);

        }
        cout << "\n\n";
    system("PAUSE");
    return EXIT_SUCCESS;
}




 

Payroll System in C++ With Colors

In this article I will show you an application that I wrote in C++ I called it Payroll System in C++ with Colors. In this application I'm Using Dev C++ as my C++ compiler it is an open source program that is very good in writing C++ codes and what is important it is free.  Below is the list of colors that can be use using C++.

Color Codes:
 
0 = Black
1 = Blue
2 = Green
3 = Aqua
4 = Red
5 = Purple
6 = Yellow
7 = White
8 = Gray
9 = Light Blue
A = Light Green
B = Light Aqua
C = Light Red
D = Light Purple
E = Light Yellow
F = Bright White

If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360


Sample Program Output

Program Listing

#include <iostream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

main(){
 string employee_name,position;
 float daily_rate=0.00,tax=0.00,sss=0.00,pag_ibig=0.00;
 float solve_salary=0.00, net_pay=0.00,total_deductions=0.00;
 int no_days_work=0;

 system("COLOR 69");
 cout << "\t ===== EMPLOYEE'S PAYROLL SYSTEM =====";
 cout << "\n\n";
 cout << "Enter Employees Name        :=>   ";
 getline(cin,employee_name);
 cout << "Enter Employees Position    :=>   ";
 getline(cin,position);;
 cout << "Enter Daily Salary Rate     :=> $ ";
 cin >> daily_rate;
 cout << "Enter Number of Day's Worked :=>   ";
 cin >> no_days_work;

  solve_salary = (daily_rate * no_days_work);

 cout << "\n\n";
 cout << "Your Gross Pay is $ " << fixed
      << setprecision(2) <<solve_salary << ".";
 cout << "\n\n";
 cout << "Enter Employee's Tax                    :=> $ ";
 cin >> tax;
 cout << "Enter Employee's SSS Contribution       :=> $ ";
 cin >> sss;
 cout << "Enter Employee's PAG-IBIG Contribution  :=> $ ";
 cin >> pag_ibig;

 total_deductions = (tax+sss+pag_ibig);
 net_pay = (solve_salary - total_deductions);

 cout << "\n\n";
 cout << "Total Deductions  $ " << fixed
      << setprecision(2) <<total_deductions << ".";
 system("COLOR A9");
cout << "\n\n";
cout << " ====== PAYROLL REPORT ======";
cout << "\n\n";
cout << " NAME : " << setw(5)<<     employee_name
      <<setw(8) << " POSITION : " << setw(5)<<  position
     << setw(8) << " NET PAY $ " << setw(5)<< net_pay;

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









Friday, March 13, 2015

Palindrome of Numbers in PHP

In this article I would like to share with you a sample program that I wrote in PHP that will accept a number and then it will check if the given number is a palindrome or not a palindrome. I called this program Palindrome of Numbers in PHP. For your information Palindrome means that when we read a word or number forward and backward it is the same for example of words that is palindrome in nature is RADAR, AMA, ANA and for numbers 141, 111, 212, 1441.  I hope you will find my work useful in your learning PHP programming.

If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360



Program Listing

<html>
<title> Palindrome of Numbers</title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
 label{
    display: table-cell;
    text-align: justify;
}
input {
  display: table-cell;
}
div.row{
    display:table-row;
}
</style>
<?php
error_reporting(0);
$number   = $_POST['numbers'];

if(isset($_POST['check'])) {
$title .= "<BR>";
$title .= " ============================= ";
$title .= " <br> ===== GENERATED RESULT ===== " ."<BR>";
$title .= " ============================= ";
$title .= "<BR><BR>";
$values=$number;

while((int)$number!=0)
{
$remainder=$number%10;
$sum=$sum*10+$remainder;
$number=$number/10;
}
if($sum==$values)
{
   $title .= "The " .$values." is a Palindrome Number.";
}
else
{
$title .= "The " .$values." is Not a Palindrome Number.";
}
     
}
if(isset($_POST['clear'])) {
  $number = " ";
  $title= " ";
   
}
?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center">Palindrome of Numbers</h2>
 <form action="" method="post"><div>
  <div class="row"><label> Enter a Number : </label> &nbsp; <input type="text" name="numbers" 
           value="<?php echo $values; ?>" autofocus required size=10/><br> </div><br>
   <div class="button">
   <input type="submit" name="check" value="Check Palindrome"   id="submit"
  title="Click here to findout if a number is palindrome or not."/>
  <input type="submit" name="clear" value="Clear" id="submit"
  title="Click here to clear text box and values on the screen"/> </div>
</form>
<br> 
<?php 
echo $title;
 ?>
  </body>
</html>

Thursday, March 12, 2015

Compound Interest Calculator in PHP

Here there in this article I would like to share with you a program that will help you compute the compounded interest in a loan you have made from a bank or financial institution. I called this program Compound Interest Calculator written entirely in PHP. What does our program will do is to ask the user the principle amount that is being loan by person, the number of years to be paid and the yearly interest rate for the said load. Every year it will be computed by our program for our user. This can be helpful for planning for the payment of the loan of the user in the future. I have a great time writing this program I hope this program will help you in your financial management.

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

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360




Program Listing

<html>
<title> Compound Interest Calculator</title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
 label{
    display: table-cell;
    text-align: justify;
}
input {
  display: table-cell;
}
div.row{
    display:table-row;
}
</style>
<?php
error_reporting(0);

$amount   = $_POST['amount'];
$years    = $_POST['years'];
$interest = $_POST['interest'];

$amount2 = (float)$amount;
$rate2   = (float)$rate;


if(isset($_POST['check'])) {
$title .= " ===== GENERATED RESULT ===== " ."<BR><BR>";
 $title .= "Total amount componded over the " . $years. " year(s)."."<br><br>";
      for($x = 1; $x <= $years; $x++) {
          $amount3 = $amount2 * pow(1+ $interest, $x);
          $title .= "Year "  .$x. "  :=> $ ".number_format($amount3,2,'.',',')."<br>";
   }
  
       
}
if(isset($_POST['clear'])) {
  $amount = " ";
  $years = " ";
  $interest = " ";
  $title= " ";
   
}
?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center"> Compound Interest Calculator</h2>
 <form action="" method="post"><div>
  <div class="row"><label> Enter Principle Amount $ : </label> <input type="text" name="amount" 
           value="<?php echo $amount; ?>" autofocus required size=10/><br> </div>
<div class="row"> <label> Enter Years of Payment  : </label><input type="text" name="years" 
           value="<?php echo $years; ?>" required size=10/><br> </div>
<div class="row"> <label> Enter Interest Rate    : </label> <input type="text" name="interest" 
           value="<?php echo $interest; ?>"  required size=10/> </div> </div>   
  <br>
   <input type="submit" name="check" value="Solve Compound Interest" 
  title="Click here to compute the compounded interest."/>
  <input type="submit" name="clear" value="Clear" 
  title="Click here to clear text box and values on the screen"/>
</form>
<br> 
<?php 
echo $title;
 ?>
  </body>
</html>


Day Checker in PHP

   In this article I would like to share with you a sample program in PHP that I wrote that will determine or check what is the day in a given date by our user using PHP as programming language I called this program Date Checker. What our program will do is very simple it will ask the user to enter the month, day and year and then our program will determine what day will fall in the given date by our user. I also added a function that will ask the user if the user want to continue using the program or not. I hope you will find my work useful in your programming assignments and projects. 

If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360




Program Listing

<html>
<head>
<title>Day Checker</title>
<head>
<style>
body { 
  font-size:25px; 
  font-family:arial;
  color:blue;
  } 
  
#banner {
  width: 750px;
  background-color: yellow;
  height: 100px;
  margin: 0 auto;
  position: inherit;
  top: 100; 
  left: 0; 
  bottom:0; 
  right: 0;
  padding: 16px 16px;
  
  border-radius: 75px;
  border: 5px solid #fba827;
}
  /* BUTTONS */

#submit {
  background: #0a7d66;
  background-image: -moz-linear-gradient(#0fb493, #0a7d66);
  background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0, #6cbb6b),color-stop(1, #0fb493));
  
  margin: 0 0 0 2px;
  padding: 15px 20px;

  border-radius: 3px 70px 70px 3px;
  -moz-border-radius: 3px 70px 70px 3px;
  border-color: #0fb493 #0da284 #0c9075;

  -moz-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
  -webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;  

  font: 16px 'Droid Serif', serif;
  background: #0fb493;
  color: blue;
  cursor: pointer;

  text-shadow: 0 5px 0 rgba(255,255,255,0.4);
}

#submit:hover {       
    background-color: #0fb493;
    background-image: linear-gradient(#0a7d66, #0fb493);
}   

#submit:active {       
    background: #0fb493;
    outline: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;        
}

#submit::-moz-focus-inner {
       border: 0;  /* Small centering fix for Firefox */
}
.inputs {
    -webkit-border-radius: 20px 3px 3px 20px;
    -moz-border-radius: 20px 3px 3px 20px;
    -ms-border-radius: 20px 3px 3px 20px;
    -o-border-radius: 20px 3px 3px 20px;
    border-radius: 20px 3px 3px 20px;

    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -ms-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
    background: yellow;
    border: 5px solid #fba827;
    color: blue;
    font: 22px 'Droid Serif', serif;
    margin: 0 0 10px;
    padding: 15px 20px 15px 20px;
    width: 150px; 
}
</style>
<?php
$month = $_POST['mon'];
$day = $_POST['day'];
$year = $_POST['year'];
error_reporting(0);

 if(isset($_POST['clear'])) {
  $month="";
  $day=""; 
  $year="";
  }
?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
   <div id="banner">
          <h1 align="center">Day Checker</h1>
      </div>
  <br>
<form name="getDate" method="post" action="">
  <table border="0" cellspacing="0" cellpadding="4">
    <tr>
      <td nowrap>
        <font size="5" face="Arial, Helvetica, sans-serif">
        Enter Date (mm/dd/yyyy): 
      </font>
      </td>
      <td nowrap>
        <font size="5" face="Arial, Helvetica, sans-serif">
        <input name="mon" type="text" size="12" maxlength="2"  value="<?php echo $month; ?>" autofocus required>
        /
        <input name="day" type="text" size="12" maxlength="2" value="<?php echo $day; ?>" required>
        /
        <input name="year" type="text" size="12" maxlength="4" value="<?php echo $year; ?>" required>       
        </font>
      </td>
      <td nowrap>
        <font size="5" face="Arial, Helvetica, sans-serif">
        Example "04/12/2001"
        </font>
      </td>
    </tr>
    <tr>
      <td>
        <font size="5" face="Arial, Helvetica, sans-serif">&nbsp;</font>
      </td>
      <td>
        <font size="5" face="Arial, Helvetica, sans-serif">
        <input type="submit" name="submit" value="Check Day" title="Click here to know the day in a given date">
        <input type="submit" name="clear" value="Clear" 
         title="Click here to clear text box and values on the screen"/>
</font>
      </td>
      <td>
        <font size="5" face="Arial, Helvetica, sans-serif">&nbsp;</font>
      </td>
    </tr>
  </table>
</form>
  
<?php  

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



$fontStyle = "size=\"5\" face=\"Arial, Helvetica, sans-serif\"";
$dayStrings = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

if (!isset($month) || !isset($day) || !isset($year))
  return;  


if (($month < 1) || ($month > 12) || 
    ($day < 1) || ($day > 31) ||
    ($year < 0))
  echo "<b>An invalid date ($month/$day/$year) was entered </b>";
  return;
}

  $t2 = array('0', '3', '2', '5', '0', '3', '5', '1', '4','6', '2', '4');
     
    $year-= $month < 3;
    $dow= ($year + $year/4 - $year/100 + $year/400 + $t2[$month-1] + $day) % 7;
echo "<font $fontStyle>";  
if ($dow > 6) { 
  echo "<br>"; 
  echo "Something is a miss, the day ($dow) is invalid";
} else {
  echo "<br>"; 
  echo "The day of the week for $month/$day/$year is:
  <b><font color='red'> $dayStrings[$dow]</font>.</b>";
}
echo "</font>";
}
?>
</body>
</html>


Day Checker in C++

In this article I would like to share with you a sample program in C++ that I wrote that will determine or check what is the day in a given date by our user using C++ as programming language. What our program will do is very simple it will ask the user to enter the month, day and year and then our program will determine what day will fall in the given date by our user. I also added a function that will ask the user if the user want to continue using the program or not. I hope you will find my work useful in your programming assignments and projects.

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

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360




Program Listing

#include <iostream>
#include <ctype.h>

using namespace std;

char *check_day(int day){
   switch(day){
      case 0 :return("SUNDAY");
      case 1 :return("MONDAY");
      case 2 :return("TUESDAY");
      case 3 :return("WEDNESDAY");
      case 4 :return("THURSDAY");
      case 5 :return("FRIDAY");
      case 6 :return("SATURDAY");
      default:return("Sorry Invalid Value Please Try Again...");
   }
}

int check_day(int month,int day,int year){
    static int t2[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
    year-= month < 3;
    return (year + year/4 - year/100 + year/400 + t2[month-1] + day) % 7;
}

int main(){
    int month=0, day=0, year=0;
    char reply;
do {
    cout << "\n";
    cout << "\t=============================";
    cout << "\n";
    cout << "\t=======[ DAY CHECKER ]=======";
    cout << "\n";
    cout << "\t=============================";
    cout << "\n\n";
    cout << "\tPLEASE ENTER MONTH DAY AND YEAR :=> ";
    cin >> month >> day >> year;
    cout << "\n\n";
    cout << "\t Day in a given date is  " << check_day(check_day(month,day,year));
    cout << "\n\n";
    cout << "\t Do you want to continue y/n :=> ";
    cin >> reply;
   } while (toupper(reply)=='Y');
    cout << "\n\n";
    cout << "\t THANK YOU FOR USING THIS PROGRAM.";
    cout << "\n\n";
}