Saturday, August 30, 2014

Password Security in C++

One of the basic protection that we can apply in our computer is the use of password. In this article I will show you a sample program that I wrote before a simple password security program in C++. What this program will do is to ask the user to enter the correct password as you run the program, every time the user type the password it display asterisk character to hide the real password underneath it protects the user from anyone who looks in their screen while they are typing for this password to access their system.

I hope you will find my work useful in your quest in learning C++ as your programming language.

Thank you very much.


Sample Screen Shoot of Our Program

Program Listing

#include <iostream>
#include <conio.h>

using namespace std;

void start();

void start()
{
    char ch;
     string password;
       system("cls");
       cout << "\n\n";
       cout << "\t\t ===== SIMPLE PASSWORD VALIDATION =====";
       cout << "\n\n";
       cout << "\t Created By: Mr. Jake Rodriguez Pomperada, MAED-IT";
      cout << "\n\n\n\n";
      cout << "Enter Your Password ==> ";

         while ((ch=getch()) != 13) {
              cout << "*";
               password+=ch;
         }

         if (password == "123") {
             cout << "\n\n\n";
             cout << "\t\t\t Password is Right Access is Granted !!!";
             cout << "\n\n\n";
             system("pause");
         }
       else {
             cout << "\n\n\n";
             cout << "\t\t\t Password is Invalid Access is Denied !!!";
             cout << "\n\n\n";
             system("pause");
             start();
    }
 }


int main() {
    start();
}



Lower Case To Upper Case Conversion in C++

This program that I wrote will show you how to convert lowercase words in a given sentence into uppercase equivalent using C++ as my programming language. The C++ library file that I used to convert lowercase into uppercase is #include <cctype> this library file has a built in function called toupper() that enables the programmer to convert lowercase characters into uppercase characters. I hope you will find my work useful and beneficial in your learning how to program in C++.

Thank you very much.



Sample Output of Our Program

Program Listing

#include <iostream>
#include <cctype>
#include <string>

int main()
{
    using namespace std;
    string str;

   cout << " Lower Case To Upper Case String Conversion 1.0";
   cout << "\n\n";
   cout << "Enter a String : ";
   getline(cin,str);
    for (size_t i = 0; i < str.length(); ++i)
    {
        str[i]=toupper(str[i]);
    }

    cout << "\n";
    cout<<"\n Converted Results in Upper Case : "  <<str << ".";
    for (size_t i = 0; i < str.length(); ++i)
    {
        str[i]=tolower(str[i]);
    }

    cout<<"\n Converted Results in Lower Case : "  <<str << ".";
    cout << "\n\n";
    system("PAUSE");
}


Vowel Omitter in C++

In this article I would like to share with you a sample program that I wrote a long time ago in my class in C++ programming I called this program Vowel Omitter. What this program will do is to ask the user to enter a sentence and then the program will remove or omit all the vowels that can be found in the words in the given sentence. I used this program to show my students in my class that C++ has many features that are suitable in string manipulation not just solving numbers.

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

Thank you very much.


Sample Output of Our Program

Program Listing

#include <iostream>

 using namespace std;

int x=0,j=0, y=0,vow=0;
int countedw(char str[150]);

main()
{

char str[150];

cout << "\n\n \t VOWEL OMITTER ";
cout << "\n\n  Created By: Mr. Jake R. Pomperada, MAED-IT";
cout << "\n\n";
cout << "Type a Sentence :=> ";
gets(str);
cout << "\n\n";
cout <<"\nOriginal Words: " <<str ;

cout<< "\n\nRemaining letters: ";
countedw(str);


cout <<"\n\nTotal No. of Omitted Vowels:  " <<vow;
cout << "\n\n";
system("pause");

}


int countedw(char str[150])

{
char tmp,tmp1;
y=strlen(str);
for(x=0; x<=y; x++)
{

tmp=str[x];

  if (tmp!='a'&&tmp!='A'&&tmp!='e'&&tmp!='E'&&tmp!='i'&&tmp!='E'&&tmp!='o'&&tmp!='O'&&tmp!='u'&&tmp!='U' )
  {
   tmp1=tmp;

  cout << tmp1;

  }else{
  vow++;
     }
   }
}

DOWNLOAD FILE HERE

Wednesday, August 6, 2014

Positive and Negative Numbers Counter in C++

One of the basic programming problems that I have developed for my C++ programming class here in the Philippines is to count the number of positive and negative numbers being given by the user of our program. My intention of creating this program is to introduce my students in my programming class how to understand and learn how to use one dimensional array as their data structure to display the positive and negative numbers in our program.

Normally arrays is one of the simplest data structure in my own opinion that can be learned easy by apply person interested in computer programming. We can define array as a list of values that has the same data type and having the same variable name also. It is very easy to manage data if we are using arrays because we are only dealing with one variable name but we can identify different values in our array by its index or elements that we access in our program. 

If order for us to determine if the number is positive is by having using this condition in our program  if (numbers[y] >=0) this condition tells us the if number[x] is greater the zero then it will display all positive numbers in our program. In our case I consider zero as positive number in our example. For checking for negative numbers and display the values of our screen I am using this condition if (numbers[y] < 0) this condition implies that if the given numbers by our user is less that zero then the values to be displayed will be negative numbers.

I hope you will find my sample program beneficial and useful in your learning how to use arrays as your data structure in your C++ program. If you have some questions about my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

Thank you very much.


Sample Output of Our Program

Program Listing

#include <iostream>

using namespace std;

main()
{
    int numbers[5];
    cout << "\n\n";
    cout << "\t Positive and Negative Numbers Counter";
    cout << "\n\n";
    for (int x=0; x<5; x++) {
        cout << "Enter item no." << x+1 <<  ": ";
        cin >> numbers[x];
     }
 cout << "\n\n";
 cout << "Positive Numbers";
 cout << "\n";
  for (int y=0; y<5; y++) {
    if (numbers[y] >=0) {
        cout << " " << numbers[y] << "";
    }
  }
  cout << "\n\n";
  cout << "Negative Numbers";
 cout << "\n";
  for (int z=0; z<5; z++) {
    if (numbers[z] <0) {
        cout << " " << numbers[z] << "";
    }
  }
 cout << "\n\n";
 cout << "\t Thank You For Using This Software.";
 cout << "\n\n";
}


Wednesday, July 30, 2014

Prime Number Checker in Python

In mathematics we refer a number that is a prime number if the number is greater than one  that has no positive dividend or divisor other than 1 and itself.  For example 7 is considered as prime number primarily because 1 and 7 are its only it positive integer factors, whereas 8 is composite because it has the divisor of 2 and 4.

I wrote this program using Python as my programming language if your find my work useful in your programming assignments and projects using Python you can send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

Thank you very much.



Sample Output of Our Program


Program Listing

# Prime Number
# Written By: Mr. Jake R. Pomperada, MAED-IT
# Tools : Python
# Date  : July 30, 2014 Wednesday

def checking_prime_number(number):
 if number > 1:

   for i in range(2,number):
       if (number % i) == 0:
           print(number,"is not a Prime Number")
           print(i,"times",number//i,"is",number)
           break
   else:
       print(number,"is a Prime Number.")
   
 else:
   print(number,"is not a Prime Number.")

complete = False

while complete == False:

  print("@==================================@")
  print("      Prime Number Checker   ")
  print("@==================================@")
  print("");
  value = int(input("Kindly Enter a Number :=> "))
  print("");
  checking_prime_number(value)
  print("")
  choice = input("Are You Finish?  Y/N: ").lower().strip()
  if choice == "y":
         complete = True
  else:
   print("\n")
  print("Thank You For Using This Program.")
 


DOWLOAD FILE HERE

Tuesday, July 29, 2014

Math Expression Solver in JavaScript

Mathematics plays an important role in our lives everyday we use math buy a product or pay for services rendered to us. Indeed having this knowledge about mathematics is very significant to survive in this world. The computer that we ca enjoying using today is based of mathematics the word computer derive from the word "compute" or to calculate. I have learned reading in the books and watching documentaries about the history of computers that is main reason why it is being developed is during the wartime in World War II to calculate the trajectory of missiles and bombs for the US military. After the war ended the US government and computer scientist and engineers try to think what is the other usage of computers that the time they make computers for commercial use in banks and business to make business transactions much easier and efficient.

In today's society computer are being used in a wide variety of applications not only in military, business, education but also in many fields. In addition computers finds its place in education to teach the students how to use it for their studies and research works and assignments. In this article I would like to share with you a program that I wrote using JavaScript as my programming language I called this program Math Expression Solver in JavaScript. What is program will do is to ask the user to enter basic mathematical expression let say (10*2) + 3 our program will find its result in this case our program will first evaluation the first expression (10*2) that will gives us the result of 20 because we multiply 10 by 2 and in computers once the expression is being put with parenthesis it will be the first one to be process or evaluated by our compiler and then 20 will be added with 3 which gives us the final result of 23.

This program is very useful among students in their mathematics subjects and other people who wish to understand how to program using JavaScript as their programming language.

If you find my work useful please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

Thank you very much.


Sample Output of Our Program




Books Information System in PHP and MySQL

The technology that we use today makes our day to day work much easier compared as before primarily because if you a computer we can search a particular record much faster, more efficient and less prone for errors compared of finding a record using a traditional filling cabinet that we must exert some effort and time just to locate a particular record that is being stored in a folder.

This can be done with the use of computer as our machine and a software called database management software which caters of storing, manipulation, retrieval and generation of reports of records. Having this application in any business can ease the processing of big amount of information and makes the transaction much faster and easier both the user and the customer.

In this article I would like to share with you a sample database application that I wrote that can be useful in finding and processing of books in a library setting I called this program Books Information System written entirely in HTML,CSS, JavaScript, PHP and MySQL as my back end database tools of storing records. What is good about this program it will help the user to manage the different books that the library was able to acquire from different book publishers it makes book inventory and monitoring a breeze and will lessen the time spend in finding the particular book from the index card cabinet. 

I hope you will find my work useful as basis in your programming projects and assignments using PHP and MySQL as your tools in developing web based database applications.

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

Thank you very much.



Sample Output of Our Program




Compound Interest Solver Using JavaScript

In today's world business plays an important role in our economy they make our nation growth, it generates jobs to our people and make our live much comfortable because we have money to spend in our day to day expenses such as foods, shelter, clothing and other basic human needs. In reality in life most of the time the income that we earn from our jobs is not sufficient enough to fill up our needs because of high cost of basic commodities like food ans shelter for example.

Most of us the easiest way is to lend money from a bank or lending institution but lending money is not an easy we must have to consider our capacity to pay such loan to avoid penalty such as big amount of monthly interest for the money that we lend from a bank or financial institution.  In this article I would like to share with you a simple program that I used in JavaScript to compute the compound interest rate of the money being loaned so that the user will able to learn and understand how much he or she must able to save and to pay for the loan they get from a bank or any lending institution.

The code is not difficult to understand it can run directly in any web browser without any problem because JavaScript programs are programs that runs on a client computers it does not need to run on the Internet most of the time. I hope you will find my work useful in your programming projects and assignments if you are using JavaScript as your developmental language of choice.

If you have some questions about my work feel free to send me and email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

Thank you very much.



Sample Output of Our Program



Viewing of Customer Records

The use of database management system today is more important as before primarily because it used in many areas in our society today. Database applications used in business, medicine, schools, engineering, military and other industries that are relying on storing, manipulation of records and generation of reports that is being used in making good decisions based of the information gathered and processed.

At present time database application can no longer seen in a desktop application the Internet is also utilize to processing this data into a useful form of information. The main advantage of web based database applications compared to desktop based application is that records can be stored, processing, retrieve and generate reports anywhere in the world as long there is an Internet connectivity. In this article I would like to share with you a simple code that I wrote using PHP and MySQL that will retrieve all the records from our database in this case I am using MySQL as my back end in storing my records in my table.

The code is very short and very easy to understand I also include an SQL dumb file for easy creation of database, tables and insertion of records in our program. You can use this program in your programming projects is your are using PHP and MySQL as your tools in creating your database application.

If you have some questions about my work feel free to send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com.

Thank you very much.



Sample Output of Our Program




Friday, July 25, 2014

Form Validation Using JavaScript

The Internet is a great place to do some research on any topics that we have in our mind. There is a lot of resources out there that we can utilize as source of information that can help us in our day to day lives. Being a web developer one of my big challenges is how to validate information being given by the visitors to my site that I working with. This can be a big headache to us if the user gives us invalid values or no values at all in our form our website is useless primarily because we can't get relevant information  from our users that can help us improve our website or clients who wish to contact us about our product or services offered through the use of Internet as our medium communication.

In this article I would like to share with you a simple JavaScript for form validation that I wrote using the JavaScript code that I was able to get freely from http://www.javascript-coder.com/. The script is very useful in making form validations that can check if the visitor of our website was able to fill up information on several fields that we lay down in our website. The script itself is free to use in your website provided you do not remove the credits of the original author of the code.

I also include the HTML and CSS file for the webpage layout and design, you may modify the code that will fit in in your needs in your website you are planning to create and implement.

If you have some question feel free to send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

Thank you very much.



Sample Output of Our Program




Multiplication Table

In order for us to improve our programming skills we must always practice and solve different programming problems that we encounter in our day to day life. One of the most interesting problem that I encounter when I started write a program is how to create a multiplication table using C++ programming language as my primary language. Maybe some people think my problem is very easy and very basic but for me even a simple problem has a place for me in improving my skills and understanding how to create good algorithm to derive a solution to the problem.

I started using nested for loop statement to generate the multiplication values by multiplying the values of variable x and y. I also use the C++ library called iomanip or its stands for input and output manipulator to give spacing of values in our program. The code is very short and very easy to understand I intended my work for beginners in C++ programming I hope they will find my work useful.

If you have some questions about my works feel free to send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com.

Thank you very much.


Sample Output of Our Program


Zip File Content of Our Program

Program Listing

#include <iostream>
#include <iomanip>

using namespace std;

main()
{
    cout << "\t    Multiplication Table";
    cout << "\n\n";
    for (int x=1; x!=11; x=x+1) {
            cout << "\n";
            for (int y=1; y<=10; y++) {
        cout << setw(4) << x*y;
            }
    }
 cout << "\n\n";
}



Thursday, July 24, 2014

Odd and Even Number Determiner in C++

Array is one of the basic data structure in programming that is very important for beginning and experienced programmers able to understand and eventually to master. By definition an array is a list of values belongs with the same variable name and data type. For example int values[100] it means I have 100 elements or index under the variable name values and its data type for all the elements is integer.

One of the common applications of arrays in computer programming for example is that we ask the user to enter five numbers and then we want to display all the five numbers being given by our user earlier in our program. There are several solution to tackle this problem but the most efficient way is to use for loop statement and an array declaration just like this one int x[5] where x has five elements or index values. 

In this article I would like to share with you one of my program that I wrote for my class in C++ programming I called this program Odd and Even Number Determiner written entirely in C++ programming language. What the program will do is very simple it will ask the user to enter ten integer numbers and then it will display the list of numbers that are Odd and Even Numbers by generating a report.

I hope you will find my work useful in learning how to user one dimensional array and for loop statements in C++.

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

Thank you very much.


Sample Output of Our Program

Program Listing

#include <iostream>

using namespace std;

main() {
 int val[10];

cout << "\n\n";
cout << "<======== ODD AND EVEN NUMBER DETERMINER ======>";
cout << "\n\n";

 for (int x=0; x<10; x++) {
    cout << "Enter item no. " << x+1 << ": ";
    cin >> x[val];
 }
cout << "\n\n";
cout << "<======= GENERATED REPORT ======>";
cout << "\n\n";
 cout << "LIST OF ODD NUMBERS";
 cout << "\n\n";
 for (int x=0; x<10; x++) {
     if (x[val] % 2 == 0) {
       }
       else {
        cout << " " << x[val] <<" ";
       }
     }
  cout << "\n\n";
 cout << "LIST OF EVEN NUMBERS";
 cout << "\n\n";
 for (int x=0; x<10; x++) {
     if (x[val] % 2 == 0) {
       cout << " " << x[val] <<" ";
       }
       else {
       }
     }
cout << "\n\n";
cout <<"\t Thank You For Using This Program.";
cout << "\n\n";
}



Friday, July 18, 2014

Disable Submit Button Until All Text Fields Has an Entry Using JQuery

Developing web applications is a challenge both the web developer and web designer but most of the time the responsibilities is being given to the web developer. One of the most challenging is how to make sure that all the text field in your web page is being filled up by your visitor of your website. As a web developer our main concern is to ensure as much as possible the all the information that is being submitted by our visitor in our website is correct and accurate.

By doing some research in the Internet I saw a code in JavaScript that uses JQuery framework that will allows the web developer to add functionality in their webpage by forcing the visitor of their website to fill up all the text fields prior it is will send the information in the web server. The code is not difficult to understand and implement below is the sample code for our webpage.

I hope you will find my work useful and beneficial in your web design and development using JQuery as your Javascript framework. If you have some questions you can send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com.

Thank you very much.


Sample Output of Our Program


Program Listing

<html>
<head>
<title>Personnel Record System</title>
  
<script src="jquery.js"></script>
 <script>
     $(document).ready(function() {
  
$(function() {
    $('#send').attr('disabled', 'disabled');
});

$('input[type=text],input[type=password]').keyup(function() {
        
    if ($('#val1').val() !=''&&
    $('#val2').val() != '' &&
    $('#val3').val() != ''&&
    $('#val4').val() != '' &&
    $('#val5').val() != '') {
      
        $('#send').removeAttr('disabled');
    } else {
        $('#send').attr('disabled', 'disabled');
    }
});
    });
</script>
  
<style type="text/css">
html { background: lightgreen; }
</style>
  </head>
  <body>
<h3>
<br>
 Fill Up Forms </h3>
  <form action="#">
     <table border="1">
     <tr>
     <td><strong>Enter Your Name :</strong></td>
<td><input type="text" name="name" id="val1" />
     </tr>
     <tr>
     <td><strong>Enter Your Address :</strong></td>
<td><input type="text" name="address" id="val2" />
     </tr>
     <tr>
     <td><strong>Enter Your Mobile Number :</strong></td>
<td><input type="text" name="mobile" id="val3" />
     </tr>
      <tr>
     <td><strong>Enter Your Email Address</strong></td>
<td><input type="text" name="email" id="val4" />
     </tr>
<tr>
     <td><strong>Enter Your Facebook Address</strong></td>
<td><input type="text" name="fb" id="val5" />
     </tr>
     <tr>
     <td colspan="2">
      <center><input type="submit" value="Submit Information"  
 title="Click here to submit information in the database." id="send" />
       
     </td>
          </form>
</body>
</html>





Tuesday, July 15, 2014

Sentinel Login Security in PHP and MySQL

Working on the web is more intimidating compared with working in a desktop environment why because in the Internet there are many people using it and they are located in different locations around the world. One of the major concern is about security this is because anyone can access your personal information in the Internet once they gain access to your account such as username and password for instance.

In this article I would like to share with you a sample program that I wrote using PHP, MySQL and JQuery I called this program Sentinel Login Security. What this program will do is to check if the user is authorized to access the website by asking the user for its username and password. Once the user provide the necessary username and password our program will search the record from the database once the record exist it will allow the user to enter in the main page and the name of the user will also display on the main page. However if the username and password cannot be found in our MySQL database our program will do a small shake animation and display the message wrong username and password. 

I also added a button to cancel the operation and the webpage will automatically close itself from the web browser. The program is very easy to understand I also added an SQL dumb file to easy creation of the database, table and insertion of sample user records.

If you have some questions about my work please don't hesitate to email me at jakerpomperada@yahoo.com and jakerpomperada@gmail.com.

Thank you very much.


Login Page of our Program


Welcome Page of our Program




Wednesday, July 2, 2014

Student Grading Record System in C++

One of the most common business applications that is widely used is Student Grading System that is being used to compute and store information about the student school academic performance. In this article I would like to share with you a simple student grading system application that I wrote using C++ programming language.

In this application I am using structure as my data structure in storing different records of the students in an array. Using structure it enables us to store and retrieve different values from our array, in this program I have five variables that is being store in our structure name student records. This variables are follows 
string   first_name[5];   string last_name[5];   int age[5];   string major_course[5]; and  float gpa_grade[5];.

Our program will accept five names of the students from the user using one dimensional array we will store those different variable entries in our array and then populate all the records afterwards in our program. This program is simple enough to give you some idea how to understand the proper way how to use one dimensional array and structure in accepting and manipulating records. In writing this program I am using Code Blocks as my text editor and Dev C++ as my C++ compiler.

In hope you will find my work useful in programming assignments and projects in C++.

Thank you very much.

Sample Output of Our Program

Program Listing

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

using namespace std;

struct student_records{

  string first_name[5];
  string last_name[5];
  int age[5];
  string major_course[5];
  float gpa_grade[5];
};

main() {

     student_records student;

     cout << "\t =========================================\n";
     cout << "\t ===== Student Grading Record System =====\n";
     cout << "\t =========================================\n";


  for (int x=0; x<5; x+=1) {
    cin.ignore();
    cout << "\n\n";
    cout << "Enter student no." <<x+1 << " First name :";
    getline(cin,student.first_name[x]);
    cout << "Enter student no." <<x+1 << " Last name  :";
    getline(cin,student.last_name[x]);
    cout << "Enter student no." <<x+1 << " Age  : ";
    cin >> student.age[x];
    cin.ignore();
    cout << "Enter student no." <<x+1 << " Majoring : ";
    getline(cin,student.major_course[x]);
    cout << "Enter student no." <<x+1 << " GPA : ";
    cin >> student.gpa_grade[x];
  }

  cout << "\n\n";
  for (int y=0; y<5; y+=1) {
     cout << "\n\n";
     cout << "Record No. " << y+1;
     cout << "\n First Name : " << student.first_name[y];
     cout << "\n Last Name  : " << student.last_name[y];
     cout << "\n Age        : " << student.age[y];
     cout << "\n Majoring   : " << student.major_course[y];
     setprecision(2);
     cout << "\n GPA        : " << student.gpa_grade[y];
     cout << "\n\n";
  }
  system("pause");

}





















Thursday, June 26, 2014

Inventory System in PHP and MySQL

One of the most commonly used business application software is called Inventory System. This type of software was designed primarily to monitor the in and outs of products, it also designed to generated reports and inform the user how many products left in the storage so the they can make an order again to replenish the product in their stock room for example.

This simple inventory system will show you the name of the product, the quantity, the individual cost and the total cost. It also sum up all the cost of all products from the database. I just wrote this code just to learn how to perform computation of values in the fields in the table without using looping statements just like For loop I'm just using SQL commands to accomplish the task. One of the things that I have discovered is the SQL statements are very easy to use and can accomplish most business operations and simple calculations with ease.

I am using PHP and MySQL as my tools in creating this Inventory System application this is not yet a complete application there are still many things that can improve I just want to show everyone how to make this application with a few commands in PHP and MySQL. I hope you will find my work useful in your programming projects in the future.

Thank you very much.

Sample Output of our Program


Program Listing

<?php
// Written By: Mr. Jake R. Pomperada, MAED-IT
// Date : June 26, 2014
// PHP and MySQL

$con=mysqli_connect("localhost","root","","values");

if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * , val_1 * val_2 AS  'total' FROM solve");
echo "\n\n";
echo "<table border='1'>
<tr>
<th align='center'>Product Name</th>
<th align='center'>Price</th>
<th align='center'>Quantity</th>
<th align='center'>Total Cost</th>
</tr>";

while($row = mysqli_fetch_array($result)) {
  echo "<tr>";
  echo "<td align='center'>" . $row['prod_name'] . "</td>";
  echo "<td align='center'>" . $row['val_1'] . "</td>";
  echo "<td align='center'>" . $row['val_2'] . "</td>";
  echo "<td align='center'> " . $row['total'] . "</td>";
  echo "</tr>";
}
echo "</table>";
$result_sum = mysqli_query($con,"SELECT * , SUM(val_1*val_2) AS  'total_sum' FROM solve");
echo "\n\n";
while($row = mysqli_fetch_array($result_sum)) {

echo "<h2> Total Cost  => Php ";

$solve = $row['total_sum'];
echo  number_format($solve,2);
echo "</h2";

}
mysqli_close($con);
?>



Friday, June 20, 2014

Odd and Even Numbers Generator in C++


One of the basic programming problem that is always given to students in programming is how to determine if the given number is an odd or even number. To check if the given number is even number is very simple a number should not have an remainder on the other hard and odd number has a remainder.

For example of odd numbers are 1,3,5,7,9,11 and even numbers are 2,4,6,8,10,12,14. In this example I will show you how to write a program to list down the numbers that are odd and even numbers. Our program will ask the user to enter 10 numbers and then our program will display the numbers that belongs to the even and odd numbers. In this sample program I am using C++ as my programming language. I hope you will find my work useful in your learning how to programming in C++.

Thank you very much.


Sample Output of Our Program


Program Listing

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

using namespace std;


  main() {

      int b[10],mod=0;
      int *mypointer;

          cout << "\t<===================================>";
          cout << "\n\t    Odd and Even Numbers Generator";
          cout << "\n\t<===================================>";
          cout << "\n\n";

           mypointer = b;

           for (int z=0; z < 10; z+=1) {
               cout << "Enter Value No. " << z+1 << ": ";
               cin >> mypointer[z];
           }
           cout << "\n \t Odd Numbers";
          cout << "\n\n";
           for (int z=0; z < 10; z+=1) {
               mod = mypointer[z] % 2;
             if (mod != 0) {
                 cout << " " << mypointer[z] << " ";
             }
           }
           cout << "\n\n";
           cout << "\n \t Even Numbers";
           cout << "\n\n";
          for (int z=0; z < 10; z+=1) {
              mod = mypointer[z] % 2;
             if (mod == 0) {
                 cout << " " << mypointer[z] << " ";
             }
          }
         cout << "\n\n";
         system("pause");
       }



Wednesday, June 18, 2014

Triangle Image in C


In this article I will show you how to write a program using C as your programming language to show an image of an triangle. We can accomplish this by using three for looping statement to repeat the display of the asterisk symbol over our screen. The code is very simple to understand and easy to learn from it I hope you will find my work useful.

Thank you very much.



Sample Output of Our Program

Program Listing

#include <stdio.h>
#include  <stdlib.h>

main()
{

int a=0,b=0,c=0,n=15;

printf("\n\n");
printf("\t  TRIANGLE");
printf("\n\n");

for(a=1;a<=n;a++)

      {

              for(c=1;c<=n-a;c++)

              {

                      printf(" ");

              }

              for(b=1;b<=(2*a)-1;b++)

              {

                      printf("*");

              }

              printf("\n");

      }
printf("\n\n");
system("pause");

}





Friday, June 13, 2014

Bubble Sort in C++

Arranging of numbers are one of the strength of computer by using programming language we were able to make our work much faster, easier and more accurate compared before using the manual operations of arranging a series of numbers. There are many sorting algorithms developed to improve the efficiency of arranging of numbers or words. One of the most versatile sorting algorithm is called bubble sort, this sorting algorithm is very simple to use it will compare all the given numbers and then compare each one of them until such time the biggest numbers are being arrange at the highest position in a given list by the user for instance.

In this article I would like to share with you my simple program that uses bubble sort algorithm to sort a series of numbers given by the user. I create a bubble sort function to take the series of numbers I store each numbers using one dimensional array and then compare its values in our bubble sort function. The function itself will first display the original arrangement of number provided earlier by our user. When we run our program our program will ask the user how many numbers is to process afterwards our program will ask the user to enter a series of numbers.

After the user enter the last number our program will immediately display the original value provided by our user and then display a series of after pass of value it shows how the values is being sorted line by line until it reaches the final sorted list of numbers. I also added a feature of our program that ask the user if he or she wants to run the program again to give another list of values to be sorted by our program.

I hope you will find my work useful in learning how to implement bubble sort using C++ as your programming language.

Thank you very much.



Sample Output of Our Program


Code:Blocks the text editor that I used to write this Bubble Sort Program.

Program Listing

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

using namespace std;

void bubble_sort(int [],int);
int main()
{
    int items[30],numbers=0,i=0;
    char reply;
    do {
     system("cls");
     cout << "\t ===== Bubble Sort Program =====";
     cout << "\n\n";
     cout << "How many items to be process : ";
     cin >> numbers;

     for(i=0;i<numbers;i++) {
     cout << "Enter element item no. " << i+1 << " : ";
     cin >>items[i];
     }
     bubble_sort(items,numbers);
  cout << "Do you want to continue y/n : ";
    cin >> reply;
    if (toupper(reply) == 'N') {
        cout << "\n\n";
        cout << "\t\t Thank You For Using This Software !!!";
        cout << "\n\n";
        break;
    }
    } while (toupper(reply!='Y'));
}

void bubble_sort(int a[],int n)
{
int i=0,j=0,k=0,temp=0;
   cout << "\n";
   cout << "Unsorted List of Values ";
   cout << "\n\n";
    for(k=0;k<n;k++)
         cout << setw(5) <<a[k];
         cout << "\n\n";
    for(i=1;i< n;i++)
    {
         for(j=0;j< n-1;j++)
         if(a[j]>a[j+1])
               {
               temp=a[j];
               a[j]=a[j+1];
               a[j+1]=temp;
               }
    cout << "After Pass Number  : " <<i<< " :=> ";
        for(k=0;k< n;k++)
            cout << setw(5) <<a[k];
            cout << "\n\n";
    }
}








Search a Number in C++

There are many ways to write a program using a particular programming language just like C++ but the question is how we can construct a program without properly identity the nature of the problem. In this article I will show you how to write a program using C++ as our programming language to search a number in a given list by our user.

I called this program search a number using C++ what the program will do is very simple it will ask the user how many numbers to be process by our program. For example let say the user type 5 it means there are five items to be accepted by our program. Assuming that the five items has a value of 1,2,3,4,5 and then our program will ask again our user what number to be search. If our user give 3 our program will look in the list if the number 3 is found in the given list. Our program will tell our user that the number 3 is in the list and its location can be found at number three.

I hope you  will find my program useful enough in your programming assignments and projects.

Thank you very much.


This is the output if the given number is found in a given list.


This is the output if the given number is not found in a given list.


I am using Code:Blocks as my text editor in writing this program.


Program Listing

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

using namespace std;

int main()
{
 int a[30],x=0,number=0,i=0;


system("cls");
cout << "====== Searching a Number =====";
cout << "\n\n";
cout <<"Enter many items :";
cin >> number;
cout << "\n";

for(i=0;i < number;i++)
{
cout << "Enter a number in item no. " << i+1 << " : ";
cin >> a[i];
}
cout << "\n\n";
cout <<"Enter the number to be search :=> ";
cin >> x;

i=0;
while(i < number && x!=a[i])
i++;

if(i < number)
{
cout << "\n\n";
cout <<"The number " <<x<<" found at the location = " <<i+1 << ".";
}
else
{
cout << "\n\n";
cout <<"The number " << x << " not found in a given list.";
}

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