Monday, July 1, 2019

Math Calculator in PHP

Here is a simple math calculator that can perform basic arithmetic operations like addition, subtraction, multiplication, and division using CSS, HTML, and PHP.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com


Sample Program Output

Program Listing

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Calculator in PHP</title>
<style type="text/css">
<!-- 
.btn {color: #0000CC; border: #FF0000 1px solid; width:150px; height:35px; font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:20px;}
.button {background-color: #999999; border:#999900 1px solid; width:100px; height:30px; color:#FFF; font-style:bold;}
.h1 {font-family:Verdana, Arial, Helvetica, sans-serif ; font-size:24px; color:#FFFFFF;}
.label {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:20px;}
.style3 {color: #FF0000; font-weight: bold; font-size:25px;  }
.style4 {color: #FF0000; font-style: italic ; font-size:12px ; padding-left:20px;}
.tr {background-color: #999999;}
.tr1 {background-color: #CC9900; border: #CCCCCC 1px solid; height:30px;}
.style12 {background-color: #999999; color: #CCFF00; }
.style14 {font-size: 24px; color: #CCFF00; }
-->
body {
 font-family:arial;
}

</style>

<script type="text/JavaScript">
<!--
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
//-->
</script>
</head>

<body >
<p>&nbsp;</p>
<form action="" method="post" name="form1" id="form1" >
  <?php
  error_reporting(0);
 //start of the code of PHP Main
if (isset($_POST['Submit']))                 // set the submit button when click
{

$value1=$_POST['value1'];                 // setting variables of the field 1 and field 2
$value2=$_POST['value2'];
$operation=$_POST['operatorbutton'];  //setting up variables with radio button
$Fresult='';
if ($value1=='' ) {                               //check the field if it is empty and post it with javascript msgbox
echo '<script language="javascript" >'  ; 
echo 'alert("Field 1 is required");';
echo'   </script>';
   }
if  ($value2=='') {                               //check the field if it is empty and post it with javascript msgbox
echo '<script language="javascript" >'  ;
echo 'alert("Field 2 is required");';
echo'   </script>';
   }
//start of the operation
if  ($operation=='') {
echo '<script language="javascript" >'  ;
echo 'alert("Division of zero is not allowed");';
echo'   </script>';}   //checking of operator if it is null
elseif($operation == 'add')   {
//addition
    $Fresult=$value1+$value2;}
    elseif ($operation == 'sub') {
//subtraction
    $Fresult=$value1-$value2;}
elseif ($operation == 'mul') {
//multiplication
$Fresult=$value1*$value2;}
elseif ($operation == 'div') 
//division
// checking if if is divided in zero and post it in a javascript
if ($value2 =='0') 
{     
echo '<script language="javascript" >'  ;
echo 'alert("Division of zero is not allowed");';
echo'   </script>';
          
  }
else   //else perform division
{$Fresult=$value1/$value2;}
}
        
     //setting all radio button to unchecked
$add = 'unchecked';
$subtract = 'unchecked';
$multiply = 'unchecked';
$divide = 'unchecked';
//setting variable for selected operator button
$selected_button = $_POST['operatorbutton'];
if ($selected_button == 'add') 
{
$add = 'checked';
}
else if ($selected_button == 'sub') 
{
$subtract = 'checked';
}
else if ($selected_button == 'mul') 
{
$multiply = 'checked';
}
else if ($selected_button == 'div') 
{
$divide = 'checked';
}
} //end of main

?>
  <table width="764" border="0" align="center" cellpadding="4" style="border:#CC9900 1px solid;">
    <tr>
      <th colspan="3" bgcolor="#CC6600" scope="col" class="tr1"><h1 class="h1">Calculator in PHP</h1></th>
    </tr >
    <tr>
      <td width="26%"><div align="right" class="label">First Number </div></td>
      <td width="1%"><span class="style3">:</span></td>
      <td width="73%" ><input name="value1" type="text" class="btn" id="value1" value="<?php echo trim($_POST['value1']); ?>" onkeypress=" return isNumberKey(event)"   /></td>  
      <!--display the error-->
    </tr>
    <tr>
      <td height="30"><div align="right" class="label">Second Number </div></td>
      <td><span class="style3">:</span></td>
      <td><input name="value2" type="text" class="btn" id="value2" value="<?php echo trim( $_POST['value2']); ?>" onkeypress=" return isNumberKey(event)"/></td>
    </tr>
    <tr class="tr">
      <td height="24"><div align="right" class="label">Math Operator</div></td>
      <td class="style3">:</td>
      <td  >
        <span class="style12">
        <input name="operatorbutton" type="radio" checked="checked" <?PHP print $add; ?>; value="add" />
        
        Addition
        <input name="operatorbutton" type="radio" value="sub" <?PHP print $subtract; ?> />
        Subtraction
        <input name="operatorbutton" type="radio" value="mul" <?PHP print $multiply; ?>/>
        Multiplication
        <input name="operatorbutton" type="radio" value="div" <?PHP print $divide; ?> />
        Division</span><span class="style14">&nbsp;</span></td>
    </tr>
    <tr>
      <td height="26"><div align="right" class="label">Result</div></td>
      <td class="style3">:</td>
      <td class="style3"><?php echo  $Fresult; ?></td>
    </tr>
    <tr>
      <td class="style4"><div align="center"></div>
          <div align="center"></div></td>
      <td>&nbsp;</td>
      <td><input name="Submit" type="submit" class="button"  value="Calculate"/>
        <input name="cmdReset" type="submit" class="button" id="cmdReset" onclick="MM_callJS('cleartext()')" value="Clear" />
        <label></label></td>
    </tr>
    <tr>
      <td colspan="3"><div align="center" class="tr1"></div></td>
    </tr>
  </table>
</form>
</body>
</html>

<!--  JAVASCRIPT FOR NOT ALLOWING THE USER TO ENTER A CHARACTER TEXT-->
 <script language="javascript" >
 function isNumberKey(evt)
  {
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 45 || charCode > 57))
return false;
return true;
  } </script>
  
<script language="javascript" >
 function cleartext()
  {
var form = document.forms[0];
//purpose?: to make the form textfield in to null
form.value1.value = "";
form.value2.value = "";
  } </script>


Decimal To Roman Numeral Converter in Visual Basic 6

Here is a program that will allow that user to convert decimal into Roman numeral using Visual Basic 6 is also a code for conversion in Permutation.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com




Sample Program Output




Telephone Billing System in C

Here is a simple telephone billing system that I wrote in C programming language that performs basic database operation CRUD (Create, Retrieve, Update and Delete) through a text file. The code will work in Dev C++ compiler that is free to download over the Internet.


I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com






Sample Program Output


Program Listing

telephone.c

/* Jake R. Pomperada */
/* July 1, 2019 */


#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#include<windows.h>
#include<stdlib.h>
struct subscriber
{
char phonenumber[20];
char name[50];
float amount;
}s;
void addrecords();
void listrecords();
void modifyrecords();
void deleterecords();
void searchrecords();
void payment();
char get;
int main()
{
int phonenumber;
char choice;


while (1)
{
system("cls");

printf("\n     **********************************************");
printf("\n    ****  TELEPHONE BILLING MANAGEMENT SYSTEM  ****");
printf("\n    ***********************************************");
   printf("\n");
      printf("\n\t A : Adding new records.\n \t L : Listing of records");
printf("\n\t M : Modifying records.\n \t P : Payments");
printf("\n\t S : Searching records.");
printf("\n\t D : Deleting records.\n\t E : Exit Program\n");
  printf("\n");
  printf("\n\t PLEASE SELECT THE LETTERS ONLY " );
choice=getche();
choice=toupper(choice);
switch(choice)
{
case 'P':
payment();break;
case 'A' :
addrecords();break;
case 'L' :
listrecords();break;
case 'M':
modifyrecords();break;
case 'S' :
searchrecords();break;
case 'D':
deleterecords();break;
case 'E':
system("cls");
printf("\n\n\t\t\t\tTHANK YOU");
printf("\n\n\n\n\n:\n\tFOR USING OUR SERVICE");
Sleep(2000);
exit(0);
break;
default:
system("cls");
printf("Incorrect Input");
printf("\nAny key to continue");
getch();
}
}
}
void addrecords()
{
FILE *f;
char test;
f=fopen("data.dat","ab+");
if(f==0)
{   f=fopen("data.dat","wb+");
system("cls");
printf("please wait while we configure your computer");
printf("/npress any key to continue");
getch();
}
while(1)
{
system("cls");
printf("\n Enter phone number:");
scanf("%s",&s.phonenumber);
printf("\n Enter name:");
fflush(stdin);
scanf("%[^\n]",&s.name);
printf("\n Enter amount:");
scanf("%f",&s.amount);
fwrite(&s,sizeof(s),1,f);
fflush(stdin);
system("cls");
printf("1 record successfully added");
printf("\n Press esc key to exit, any other key to add other record:");
test=getche();
if(test==27)
break;
}
fclose(f);
}
void listrecords()
{
FILE *f;
int i;
if((f=fopen("data.dat","rb"))==NULL)
exit(0);
system("cls");
printf("Phone Number\t\tUser Name\t\t\tAmount\n");
for(i=0;i<79;i++)
printf("-");
while(fread(&s,sizeof(s),1,f)==1)
{
printf("\n%-10s\t\t%-20s\t\t $. %.2f /-",s.phonenumber,s.name,s.amount);
}
printf("\n");
for(i=0;i<79;i++)
printf("-");

fclose(f);
getch();
}
void deleterecords()
{
FILE *f,*t;
int i=1;
char phonenumber[20];
if((t=fopen("temp.dat","w+"))==NULL)
exit(0);
if((f=fopen("data.dat","rb"))==NULL)
exit(0);
system("cls");
printf("Enter the phone number to be deleted from the Database");
fflush(stdin);
scanf("%[^\n]",phonenumber);
while(fread(&s,sizeof(s),1,f)==1)
{
if(strcmp(s.phonenumber,phonenumber)==0)
{       i=0;
continue;

}
else
fwrite(&s,sizeof(s),1,t);
}
if(i==1)
{       system("cls");
printf("Phone number \"%s\" not found",phonenumber);
remove("data.dat");
rename("temp.dat","data.dat");
getch();
fclose(f);
fclose(t);
main();
}
remove("data.dat");
rename("temp.dat","file.dat");
system("cls");
printf("The Number %s Successfully Deleted!!!!",phonenumber);
fclose(f);
fclose(t);
getch();
}
void searchrecords()
{
FILE *f;
char phonenumber[20];
int flag=1;
f=fopen("data.dat","rb+");
if(f==0)
exit(0);
fflush(stdin);
system("cls");
printf("Enter Phone Number to search in our database");
scanf("%s", phonenumber);
while(fread(&s,sizeof(s),1,f)==1)
{
if(strcmp(s.phonenumber,phonenumber)==0)
{ system("cls");
printf(" Record Found ");
printf("\n\nPhonenumber: %s\nName: %s\nAmount: $ %0.2f\n",s.phonenumber,s.name,s.amount);
flag=0;
break;
}
else if(flag==1)
{ system("cls");
printf("Requested Phone Number Not found in our database");
}
}
getch();
fclose(f);
}
void modifyrecords()
{
FILE *f;
char phonenumber[20];
long int size=sizeof(s);
if((f=fopen("data.dat","rb+"))==NULL)
exit(0);
system("cls");
printf("Enter phone number of the subscriber to modify:");
scanf("%[^\n]",phonenumber);
fflush(stdin);
while(fread(&s,sizeof(s),1,f)==1)
{
if(strcmp(s.phonenumber,phonenumber)==0)
{
system("cls");
printf("\n Enter phone number:");
scanf("%s",&s.phonenumber);
printf("\n Enter name: ");
fflush(stdin);
scanf("%[^\n]",&s.name);
printf("\n Enter amount: ");
scanf("%f",&s.amount);
fseek(f,-size,SEEK_CUR);
fwrite(&s,sizeof(s),1,f);
break;
}
}
fclose(f);
}
void payment()
{
FILE *f;
char phonenumber[20];
long int size=sizeof(s);
float amt;
int i;
if((f=fopen("data.dat","rb+"))==NULL)
exit(0);
system("cls");
printf("Enter phone number of the subscriber for payment");
scanf("%[^\n]",phonenumber);
fflush(stdin);
while(fread(&s,sizeof(s),1,f)==1)
{
if(strcmp(s.phonenumber,phonenumber)==0)
{
system("cls");
printf("\n Phone No.: %s",s.phonenumber);
printf("\n Name: %s",s.name);
printf("\n Current amount: %f",s.amount);
printf("\n");
for(i=0;i<79;i++)
printf("-");
printf("\n\nEnter amount of payment :");
fflush(stdin);
scanf(" %f",&amt);
s.amount=(amt-s.amount);
fseek(f,-size,SEEK_CUR);
fwrite(&s,sizeof(s),1,f);
break;
}
}
system("cls");
printf("THANK YOU %s FOR YOUR TIMELY PAYMENTS",s.name);
getch();
fclose(f);
}