Friday, October 17, 2014

Basic Math Operations in Perl

I love to learn many things in life programming is not an exception there are thousands of programming language around us. Each one of them has a basic application just like PHP it is design for web development, C and C++ was design to use in system programming that interact with computer hardware and peripherals. One of the programming language that caught in my attention is PERL or Practical Extraction  Reporting Language developed by Larry Wall way back in 1987 to help him in his job as system administrator.

This programming language is often called the swiss army knife in programming community because it has many application not only in console but also in web development.  My experience in Perl is very fundamentals in a sense it is my outlet from my day to day work. I found Perl easy to use and delivers result effectively however in today's IT environment most of the web application specially here in the Philippines uses PHP as their primary language by many web developers maybe because there are many frameworks like WordPress, Drupal and Joomla that is written most of the time in PHP. Again I have to emphasize I do not compare this programming languages because each one of them has a specific application.  

This sample Perl program is my first time to create a web based program using Perl as my programming language. Most of my program in Perl is written in console environment I am using XAMPP as my Perl compiler and interpreter in this sample program. What is program will do is to show the use basic mathematical operations using Perl. The basic math operations are addition, subtraction, division and multiplication. The web browser that is used to run this program is torch a similar browser like google chrome.

If you find my work useful in your programming projects and assignments please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

Thank you very much.


Sample Output of Our Program

Program Listing

#!"D:\xampp\perl\bin\perl.exe"
print "Content-Type: text/html\n\n";

$a=10;
$b=5;
$add = ($a + $b);
$subtract  = ($a - $b);
$multiply = ($a * $b);
$division  = ($a / $b);

print "<hr size='10' color='green'>";
print "<center> <h2> <font color='blue' face='arial'> Basic Math Operations in Perl
  </h3> </center> </font>";
print "<hr size='10' color='green'>";
print "<br>";
print " <font color='red' face='comic sans ms' size='6'>Original Values for variable A is $a and
       for variable B is $b <br> </font>";
print "<br><br>";
print "<font color='blue' face='arial' size='5'>The sum of $a and $b is $add. </font> <br>";
print "<font color='blue' face='arial' size='5'>The difference between $a and $b is $subtract. </font> <br>";
print "<font color='blue' face='arial' size='5'>The product of $a and $b
     is $multiply. </font> <br>";
print "<font color='blue' face='arial' size='5'>The quotient of $a and $b
     is $division. </font> <br>";
print "<br><br>";
print "<font color='blue' face='comic sans ms' size='6'> End of Program</font> <br>";

 

DOWNLOAD SOURCE CODE HERE







Thursday, October 16, 2014

Email Address Checker

In this article I would like to share with you a sample program that will check whether the email address that is being given by the user is valid or invalid using C++ as my programming language.

If you like 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;

bool check1(char* Address,bool Logic)


    {
    int bilA=0;
    for(int Loop1=0; Loop1<255; Loop1++)


        {
        if(Address[Loop1]=='@')


            {
            bilA++;
            if(Address[Loop1-1]==' '||Address[Loop1+1]==' ')


                {
                Logic = false;
                cout << "\n\a\t\tNo empty space before or after @!";
                break;
            }
        }
    }
    if (bilA<1||bilA>1)


        {
        Logic = false;
        cout << endl << "\a\t\tRecheck your number of @!" << endl;
    }
    return Logic;
}
bool check2(char* Address,bool Logic)


    {
    int bilDOT = 0;
   for(int Loop2=0; Loop2<255; Loop2++)


        {
        if(Address[Loop2]=='.')


            {
            bilDOT++;
            if(Address[Loop2-1]==' '||Address[Loop2+1]==' ')


                {
                Logic = false;
                cout << "\n\a\t\tNo empty space before or after dot!";
                break;
            }
        }
    }
    if (bilDOT<1||bilDOT>1)


        {
        Logic = false;
        cout << endl << "\a\t\tRecheck your number of dot!" << endl;
    }
    return Logic;
}


int main()


    {
    int Characters = 0;
    int Select;
    char Address[255] = "";


        bool Logic = true;

             cout << "\n\n\t\t  EMAIL ADDRESS CHECKER VERSION 1.0";
             cout << "\n\n\t  Created By: Mr. Jake Rodriguez Pomperada,MAED-IT";
             cout << "\n\n";
             cout << "\n\tEnter Your Email Address: ";
            cin.ignore();
            cin.get(Address,255,'\n');
            cin.ignore();
            Characters = strlen(Address);
            if(Logic)


                {
                Logic = check1(Address,Logic);
                Logic = check2(Address,Logic);
            }
            if(Address[0]=='@'||Address[Characters-1]=='@')


                {
                cout << endl << "\t\t\a@ misplaced at ends!" << endl;
                Logic = false;
            }
            if(Logic)


                {
                cout << "\n\t\t[ YOUR EMAIL IS VALID ]";

            }
            else


                {
                cout << "\n\t\t[ INVALID EMAIL!! ]";

            }

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

}

Thursday, October 9, 2014

Area of the Circle using Perl

In this article I would like to share with you a sample program to solve the area of the circle by this time I am using Perl as my programming language. The code is very simple and easy to understand.

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

## Written By: Mr. Jake R. Pomperada, MAED-IT
## Language : Perl
## Date     : October 9, 2014
#!usr/bin/perl
print "\n\n";
print "\t Area of the Circle";
print "\n\n";
print "Enter the Radius of the Circle? : ";
chomp ($radius=<>);
###########################################
## Formula to solve the area of the Cirle
$area = (3.14 * ($radius ** 2));
###########################################
print "\n\n";
print "The radius of the circle is $radius. \n";
print "The area of the circle is $area.";
print "\n\n";
print "\t\t Thank You For Using This Program.";
print "\n\n";

Addition of Three Numbers Using Perl

In this article I would like to share with you a very simple program that I wrote using Perl as my programming language. I am a beginner in terms of experience in writing codes using Perl or Practical Extraction Reporting Language.

A programming language developed by one of my favorite programmer Larry Wall way back in 1987 to help him in his system administration work before. This programming language is primarily used in server administration and web programming. What this program will do is to ask the user to enter three numbers and then our program will display the total sum of the three values early provided by our user.

If you have some questions regarding with my work in programming feel free to contact me through my email address at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

Thank you very much.


Sample Output of Our Program

Program Listing

#!usr/bin/perl
print "\n\n";
print "\t Addition of Three Numbers";
print "\n\n";
print "Enter First Number  : ";
chomp($a=<>);
print "Enter Second Number : ";
chomp($b=<>);
print "Enter Third Number  : ";
chomp($c=<>);

$total_sum = ($a+$b+$c);
print "\n";
print "The total sum of $a, $b and $c is $total_sum.";
print "\n";
print "\t\t Thank You For Using This Program.";
print "\n\n";


 DOWNLOAD SOURCE CODE HERE
 



Print a Web Page Using JavaScript

In this article I will show you how to print a portion of your webpage using JavaScript as your scripting language. The code is very simple and short and can be used in your report generation in you website. I hope you will find my work useful in your web design and programming.

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

Thank you very much.




Sample Output of Our Program


Find a Number in C++

In this article I would like to share with you a simple program that I wrote using C++ as my programming language to perform linear search or sequential search in computer science data structure. I called this program find a number. What this program will do first is to ask the user to enter five integer numbers after that our program will ask the user what number to be search in a given list. If the number can be found in the list our program will tell the user which location the value is located. If the number is not in the list our program will tell the user the value to be search cannot be found in the list.

I hope you will find my program useful in you programming assignments and projects using C++ as your primary programming language. 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>
#include <stdlib.h>

using namespace std;

main() {

    int list=0,numbers[5];
    int search=0,dummy=0,location=0;
    int *mypointer;

     cout << "\n\t\t\tFIND A NUMBER 1.0";
     cout << "\n\n";

      mypointer = numbers;

    for (list=0; list < 5; list++) {
        cout << "Enter Value No. " << list+1 <<  " :" ;
        cin >> list[mypointer];
    }

   cout << "\n\n";
   cout << "Enter Number To Search : ";
   cin >> search;

   dummy = search;
     for (list=0; list < 5; list++) {
         if (search == list[mypointer]) {
            search = 1; // true value if found in the list
            location = list+1; // Determine the exact location of the number
     }
}
  if (search == 1){
       cout << "\n\n";
      cout <<"The number " << dummy <<
            " is found in the list";
      cout << "\n\n";
      cout << "The Exact Location in list is " <<
            location <<".";
  }
  else {
       cout << "\n\n";
      cout <<"The number " << dummy<<
            " Cannot be found in the list";
  }
  cout << "\n\n";
 system("PAUSE");
}


Wednesday, October 8, 2014

Menu Program in C++

This code that I wrote in C++ is a simple menu driven program that demonstrates how to construct a menu using C++. What is good about this program is that it does not accept invalid entries there's no way our menu program will crash for invalid entries from our user. I hope this program can help other people how to make their own menu program using C++ as there programming language.

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

Thank you very much.


Sample Output of Our Program

Program Listing

// Created By: Mr. Jake Rodriguez Pomperada, MAED-IT
// Date : April 3, 2010 Saturday
// Tool : C++
// Email : jakerpomperada@yahoo.com
// Facebook Address : jakerpomperada@yahoo.com

#include <iostream>

using namespace std;

void  menu()
{
    char choice;
        system("cls");
        cout << "\n\t\t     MENU DEMO Version 1.0 ";
        cout << "\n\n\t Created By: Mr. Jake R. Pomperada, MAED-IT";
        cout << "\n\n";
        cout << "\n\t\t\t 1. Add Record ";
        cout << "\n\t\t\t 2. Edit Record ";
        cout << "\n\t\t\t 3. Delete Record ";
        cout << "\n\t\t\t 4. View Record ";
        cout << "\n\t\t\t 5. Quit Program ";
        cout << "\n\n";
        cout << "\n\t\t Enter Your Choice :=> ";
        cin >> choice;
        if (choice == '1') {
            cout << "\n\n You select Add";
            cout << "\n\n";
            system("pause");
            menu();
        }
        else if (choice == '2') {
            cout << "\n\n You select Edit";
            cout << "\n\n";
            system("pause");
            menu();
        }
    else if (choice == '3') {
            cout << "\n\n You select Delete";
            cout << "\n\n";
            system("pause");
            menu();
        }
        else if (choice == '4') {
            cout << "\n\n You select View";
            cout << "\n\n";
            system("pause");
            menu();
        }
         else if (choice == '5') {
            cout << "\n\n\tThanks for using this program and return to OS.";
            system("pause");
            menu();
        }
     else if (choice != '5') {
         cout << "\n\n\n \t\t\t Invalid Option Try Again...";
         cout << "\n\n";
        system("pause");

    }

}

main()
{
 char choice;
    do {
    menu();
    } while (choice != '5');
}


Sunday, October 5, 2014

Electricity Billing System in C++

In this article I would like to share with you my program that I wrote a long time ago in C++ I called this program electricity billing system. It is a menu driven program that will compute and generate bill reports of the consumer of electricity. What good of this program is the it is very easy to use and the code is very simple to understand by beginners in C++ programming.

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

Thank you very much.



Sample Output of Our Program




Saturday, October 4, 2014

Stop Watch in Visual Basic 6


A simple stop watch application that I wrote using Microsoft Visual Basic 6. The code uses timer control to generate time in seconds in Visual Basic 6. The code is very short and easy to understand for beginners that are new in Visual Basic programming.

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

Private Sub cmdstart_Click()
    lbltime.Caption = "0"
    tmrwatch.Enabled = True
End Sub

Private Sub cmdstop_Click()
    tmrwatch.Enabled = False
End Sub

Private Sub Command1_Click()
Unload Me
End Sub

Private Sub Form_Load()
    tmrwatch.Interval = 100
End Sub

Private Sub tmrwatch_Timer()
    lbltime.Caption = Str(Val(lbltime.Caption + 0.1))
End Sub

DOWNLOAD SOURCE CODE HERE

Scrolling Text in Visual Basic 6.0


A simple animation program that I wrote using Microsoft Visual Basic 6 to scroll a text in the form. I use timer control to generate the animation effects.

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

Thank  you very much.



Sample Output of Our Program

Program Listing

Option Explicit
Dim strText As String

Private Sub cmdScroll_Click()
    strText = String(70, " ") + " Microsoft Visual Basic 6.0 "
    Timer1.Enabled = True
End Sub

Private Sub cmdQuit_Click()
Unload Me
End Sub

Private Sub Timer1_Timer()
    strText = Mid(strText, 2) & Left(strText, 1)
    txtMessage = strText
End Sub




Loan Interest Calculator in Visual Basic 6

A simple program that I wrote using Microsoft Visual Basic 6 to compute the loan by the customer based on the amount being loaned, number of years and the interest rate. The code is very simple and easy to understand.

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

Thank you very much.



Sample Output of Our Program






Login System Using Microsoft Access

A login security system that I wrote in Microsoft Access to check if the user is a valid or not in the system. Im using VBA code for this application very code to understand. The code is very simple to understand and can be used as your basis in creating your own login security system for your Microsoft Access database applications.

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






Number To Words Currency Converter in MS Access

This program that I wrote using Microsoft Ms Access 2007 as my programming language will ask the user to enter a number in numeric format and then the program will translate the numbers into words in currency.

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

Thank you very much.


Sample Output of Our Program


Student Grading System in Java


This Java application will compute and display the grade of the student in a class. What is good about this program is that it is a menu driven application it means it is very easy to use and can be helpful to the part of the teacher to process the grades of their perspective student.

I wrote this student grading system in Java using JCreator and Java SE compiler I hope my work will help you our in your programming projects and assignments using Java as your programming language.

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



Tuesday, September 30, 2014

Centimeter To Feet Converter in JavaScript

This program that I wrote in JavaScript will convert the height of the person from centimeter to feet. I'm using HTML as my markup language and JavaScript to perform as series of computation and conversion of values from centimeter to feet. I hope you will find my work useful in your programming projects and assignments using JavaScript.

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

<HTML>
<TITLE> Height Converter </TITLE>
<BODY BGCOLOR="lightgreen">
<font face="comic sans ms" size=5>
<TABLE cellSpacing=0 cellPadding=0 width=250 border=0>
<H3>  Height Converter </center> </H3>
<FORM name=cminch>
        <TBODY>
        <TR>
          <TD>
            <FONT face="comic sans ms"><INPUT 
            onblur=cmconvert() value=2.54 name=cm> CM</FONT></TD>
        </TR>
        <TR>
          <TD>
            <FONT face="comic sans ms"><INPUT 
            onblur=feetconvert() value=0 name=feet> </FONT>FEET </TD>
        </TR>
        <TR>
          <TD>
            <FONT face="comic sans ms"><INPUT 
            onblur=inchconvert() value=1 name=inch> </FONT>INCHES</TD>
        </TR>
        <TR>
          <TD width="50%">
              <p align="center"><input type="button" value="Submit" name="B3"></p>
          </TD>
        </TR></TBODY></FORM></TABLE>
      <p align="left">
      <FONT face="Comic Sans Ms" size="3">Note: 1 Inch = 2.54 cm, 1 Feet = 30.48 cm, 1 
      Feet = 12 Inch</FONT>
      <BR>

<SCRIPT language=JavaScript>


function roundit(which){
return Math.round(which*100)/100
}

function cmconvert(){
with (document.cminch){
feet.value = roundit(cm.value/30.84);
inch.value = roundit(cm.value/2.54);
}
}

function inchconvert(){
with (document.cminch){
cm.value = roundit(inch.value*2.54);
feet.value=roundit(inch.value/12);
}
}

function feetconvert(){
with (document.cminch){
cm.value=roundit(feet.value*30.48);
inch.value=roundit(feet.value*12);
}
}

</SCRIPT>
</font>
</body>

DOWNLOAD FILE HERE

Text Field Checker Using JQuery

This program that I wrote in PHP,HTML and JQuery will check if all the required fields are being filled up by the visitor of our website. I use JQuery for checking the empty text field in our webpage I hope you will find my work useful in your web design and development.

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


Compound Interest Solver in JavaScript

One of my favorite scripting programming language is JavaScript in this program I wrote a simple Compound Interest Solver that will solve for the interest rate for the loan made by the person. The code is very simple and easy to understand, I'm using notepad++ as my test editor in writing this 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

<!-- Written By: Jake R. Pomperada, MAED-IT  2014-->
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var princ;
var ratepc;
var years;
var rate;
var power;
function calcAmt(frm) {
princ = eval(frm.pr.value);
ratepc = eval(frm.rt.value);
years = eval(frm.yr.value);
rate = ratepc / 100;
power = Math.pow((1 + rate), years);
frm.amt.value = Math.round(princ * power * 100) / 100;
frm.inter.value = Math.round((frm.amt.value - princ) * 100) / 100;
}
function checkInput(frm) {
if (rate == 0 || rate > .3) {
window.alert ("Are you sure that the interest rate is " + ratepc +"%?");
frm.rt.focus();
}
if (years == 0 || years > 30) {
window.alert ("Are you sure that the term is " + years + " years?");
frm.yr.focus();
   }
}
//  End -->
</script>

</HEAD>


<BODY BGCOLOR="LIGHTGREEN">

<center>
<hr>
<h1> <font face="comic sans ms"> COMPOUND INTEREST SOLVER  </h1>
<hr>
<br> <br>
<font size=5>
<form method=get name=frm>
Principal <input type=text name=pr size=10 maxlength=10 onChange=calcAmt(this.form)>
Rate <input type=text name=rt size=6 maxlength=6 onChange=calcAmt(this.form)>
Years <input type=text name=yr size=5 maxlength=5 onChange=calcAmt(this.form)>
<br>
<br>
<input type=button name=calc value="Calculate" size=10 onClick=checkInput(this.form); calcAmt(this.form);>
<input type=reset value="Clear">
<br>
<br>
Amount <input type=text name=amt size=10>
Interest <input type=text name=inter size=10>
</form>
</font>
</font>
</center>
</body>
</html>


Zodiac Sign Checker in PHP

This code is being given to us by my friend named Alfredo Soliva an IT student here in the Philippines in their programming class in PHP and MySQL programming. I am very happy that some programmers and students visiting my website and sharing their codes to help our fellow programmers and software engineers.

What that program will do is to ask the user to select form the combo box the month and day and then the program will check what zodiac sign belongs the user of our program. The code uses also some JavaScript for form validations and CSS for the design of the webpage. I hope the work of our friend Alfredo gives you an idea how to program in PHP.

Thank you very much.



Sample Output of Our Program

Program Listing

index.html

<html>
<head>
<title>Activity No. 1 Zodiac Sign</title>
<style type="text/css">
body {
background:#00FFFF;
}
#header {
width: 100%;
height: 120px;
background: #202020;
text-align: center;
font-size:xx-large;
}

#zodiac {
color: #999999;
font-weight: bold;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: xx-large;
}
#zodiac:hover{
color:white;
}
#monthdate {
position:absolute;
left:40%;
top:100px;
}
#footer{
height: 40px;
border-top: 1px solid gray;
text-align: center;
font-size: 14px;
}
</style>
</head>
<body>

<div id="header">
 <h1 class="style1" id="zodiac">ZODIAC SIGN</h1>
</div>

<div id = "monthdate">
<form method = POST action = result.php>
<!-- display dropdown list for month -->
<select name="month" id="month" onChange="adlaw(this.value)">
<option value = "0" disabled = "disabled" selected = " ">Month</option>
<option value = "1">January</option>
<option value = "2">February</option>
<option value = "3">March</option>
<option value = "4">April</option>
<option value = "5">May</option>
<option value = "6">June</option>
<option value = "7">July</option>
<option value = "8">August</option>
<option value = "9">September</option>
<option value = "10">October</option>
<option value = "11">November</option>
<option value = "12">December</option>
</select>
<!-- display dropdown list for day -->
<select name = "day" id = "day">
<option value = "day" disabled = "disabled" selected = " ">Day</option>
</select>
   <input type="submit" name="btnzodiac" value="Get My Zodiac">
</form>
</div>
<div id="footer">
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p><br />
  &copy; 2014 Midterm Project. Alfredo Rodriguez Soliva Jr./ All rights reserved.</p>
</div>

</body>

<script type="text/javascript">

var me;
var theLeap = document.getElementById("leap"); 
var theDay = document.getElementById("day"); 
var theMonth = document.getElementById("month");
var x; 

function adlaw(me){

if(me==4 || me==6 || me==9 || me ==11){
displayday(30);
}
else if(me==1 || me==3 || me==5 || me==7 || me==8 || me==10 || me==12){
displayday(31);
}
else if(me==2){
x = prompt ("enter your choice 'Y' for leap year 'N' if not");
if (x == 'y' || x == 'Y')
{
displayday(29);
}
else if (x == 'n' || x == 'N')
{
displayday(28);
}
else
{
alert ("please make a selection");
}
}
}

function displayday(num){ 
theDay.innerHTML=""; 
for(var ctr=1;ctr<=num;ctr++){ 
theDay.innerHTML = theDay.innerHTML+'<option value='+ctr+'>'+ctr+'</option>';
}
}

</script>

</html>

result.php

<html>
<style type="text/css">
body{
background-color:#99FFFF;
font-family:Geneva, Arial, Helvetica, sans-serif;
font-size:xx-large;
text-align:center;
}
#header {
width: 100%;
height: 120px;
background: #202020;
text-align: center;
font-size:xx-large;
color:#CCCCCC;
}

#header:hover {
color:#FFFFFF
}

#body:hover {
color:white;
}

#result:hover{
color:white;
font-size:50px;
}



</style>

<body>

<div id="header">
 <h1 class="style1" id="zodiac">Your ZODIAC SIGN</h1>
</div>
<div id="result">
<?php
$month = $_POST['month'];
$day = $_POST['day'];
if (($month == '3') && ($day>21) || ($month == '4') && ($day<19)){
print 'Aries.';
} elseif (($month == '2') && ($day>20) || ($month == '3') && ($day<20)){
print 'Pisces.';
} elseif (($month == '4') && ($day>20) || ($month == '5') && ($day<20)){
print 'Taurus.';
} elseif (($month == '5') && ($day>21) || ($month == '6') && ($day<20)){
print 'Gemini.';
} elseif (($month == '6') && ($day>21) || ($month == '7') && ($day<22)){
print 'Cancer.';
} elseif (($month == '7') && ($day>21) || ($month == '8') && ($day<22)){
print 'Leo.';
} elseif (($month == '8') && ($day>23) || ($month == '9') && ($day<22)){
print 'Virgo.';
} elseif (($month == '9') && ($day>23) || ($month == '10') && ($day<22)){
print 'Libra.';
} elseif (($month == '10') && ($day>23) || ($month == '11') && ($day<22)){
print 'Scorpio.';
} elseif (($month == '11') && ($day>23) || ($month == '12') && ($day<21)){
print 'Sagittarius.';
} elseif (($month == '12') && ($day>22) || ($month == '1') && ($day<21)){
print 'Capricorn.';
} elseif (($month == '1') && ($day>19) || ($month == '2') && ($day<19)){
print 'Aquarius.';
} else {  
print 'No information available';
}
?>
</div>
</body>

</html>

DOWNLOAD FILE HERE

Tuesday, September 16, 2014

Celsius To Fahrenheit Solver in Bash

This is another conversion of temperature that I wrote using Bash script. In my previous article I wrote a program that will ask the user to enter the temperature in Fahrenheit and then it will convert to its Celsius temperature equivalent. By this time it another way around from Celsius it will convert to its Fahrenheit value.

Take note in my sample bash program I always adding some functionalities like asking the user if the user wants again to run the program so that it can give a different value and then give us the different converted values. It makes our bash script more versatile in many ways. I hope you will find my sample bash script programs more useful in your learning how to program in bash in UNIX, MAC OS and Linux environment.

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

#!/bin/bash

# Celsius To Fahrenheit Solver
# Written By Mr. Jake R. Pomperada, MAED-IT
# Operating System : UBUNTU 14.04
# Date : September 16, 2014

start()
{
clear
echo -e "\n"
echo -e "\t (====== CELSIUS TO FAHRENHEIT SOLVER  =====)";
echo -e "\n"

read -p  "Please Enter Temperature in Celsius : " celsius_values
compute=$(echo "scale=2;((($celsius_values * 9/5 +32)))"|bc)

echo -e "\nTemperature in Celsius is $celsius_values\xe2\x84\x83 ."
echo -e "The equivalent temperature in Fahrenheit is $compute\xe2\x84\x83."

while true; do
  echo -e "\n"
  read -p "More (Y/N)? " answer
  case $answer in
       [Yy]* ) start;  break;;
       [Nn]* ) bye; break;;
       * ) echo "Please answer yes or no. ";;
  esac
done
}

bye()
{
echo -e "\n"
echo -e "\t Thank You For Using This Program.";
echo -e "\n\n";
}

start