Sunday, April 30, 2017

Decimal To Roman Numeral in Visual Basic NET

Here is a sample program to ask the user to give a number and then it will convert in Roman Numeral equivalent using Microsoft Visual Basic NET.  The code is very short and easy to understand. Thank you.

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

My mobile number here in the Philippines is 09173084360.






Sample Program Output


Program Listing


Public Class Form1
    Private Function ConvertRoman(ByVal n As Integer) As String
        If n = 0 Then ConvertRoman = "0" : Exit Function
        Const r = "IVXLCDM"
        Dim i As Integer = Math.Abs(n)
        Dim s As String = ""

        For p As Integer = 1 To 5 Step 2
            Dim d As Integer = i Mod 10
            i = i \ 10
            Select Case d '
                Case 0 To 3 : s = s.PadLeft(d + Len(s), Mid(r, p, 1))
                Case 4 : s = Mid(r, p, 2) & s
                Case 5 To 8 : s = Mid(r, p + 1, 1) & s.PadLeft(d - 5 + Len(s), Mid(r, p, 1))
                Case 9 : s = Mid(r, p, 1) & Mid(r, p + 2, 1) & s
            End Select
        Next

        s = s.PadLeft(i + Len(s), "M")
        If n < 0 Then s = "-" & s
        ConvertRoman = s
    End Function
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Label2.Text = " The equivalent value of " & TextBox1.Text & " is " & ConvertRoman(TextBox1.Text) & "."
    End Sub

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

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        End
    End Sub
End Class




Decimal To Roman Numeral in Visual Basic 6

Here is a sample program that will ask the user to give a number and then it will be converted into roman numeral value using Visual Basic 6.

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

My mobile number here in the Philippines is 09173084360.






Sample Program Output


Program Listing

Public Function ConvertRoman(ByVal n As Integer) As String
   If n = 0 Then FormatRoman = "0": Exit Function
    
   Const r = "IVXLCDM"
   Dim i As Integer: i = Abs(n)
   Dim s As String, p As Integer
   For p = 1 To 5 Step 2
      Dim d As Integer: d = i Mod 10: i = i \ 10
      Select Case d
         Case 0 To 3: s = String(d, Mid(r, p, 1)) & s
         Case 4:      s = Mid(r, p, 2) & s
         Case 5 To 8: s = Mid(r, p + 1, 1) & String(d - 5, Mid(r, p, 1)) & s
         Case 9:      s = Mid(r, p, 1) & Mid(r, p + 2, 1) & s
         End Select
      Next
   s = String(i, "M") & s
   If n < 0 Then s = "-" & s
   ConvertRoman = s
   End Function


Private Sub Command1_Click()
Label2.Caption = "The equivalent value of " & Text1.Text & " is " & ConvertRoman(Text1.Text) & "."
End Sub

Private Sub Command2_Click()
End
End Sub



Wednesday, April 26, 2017

Leap Year Checker Using Two Dimensional Array in C++

Here is a sample program that I wrote a very long time ago while I am teaching in one of the university in Bacolod City, Negros Occidental Philippines in my C++ class. This program will ask the user to give a series of years and then our program will check if the given year is a leap year or not using two dimensional array.  I am using CodeBlocks as my text editor and Dev C++ as my C++ compiler in this sample program. I hope you will find my work useful. Thank you.

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

My mobile number here in the Philippines is 09173084360.



Program Listing

#include <iostream>

using namespace std;


 main()
{

int years[2][2];

  cout << "\n\n\t\t\t LEAP YEAR LISTER 1.O";
  cout << "\n\t Created By: Mr. Jake Rodriguez Pomperada,MAED-IT";
  cout << "\n\n";
for (int row=0; row <2; row++) {
    for (int col=0; col <2; col++) {
        cout << "Enter Year :=> ";
        cin >> years[row][col];
    }
}
cout << "\n\n";
// Leap Year
cout << "LIST OF LEAP YEAR";
cout << "\n\n";
for (int row=0; row <2; row++) {
    for (int col=0; col <2; col++) {

if (years[row][col]%4==0)
{
cout << " " << years[row][col] << " ";
}

    }
}

cout << "\n\n";
// not a leap year
cout << "LIST OF NOT A LEAP YEAR";
cout << "\n\n";
for (int row=0; row <2; row++) {
    for (int col=0; col <2; col++) {
        if (years[row][col]%4==0)
{

}
  else {
      cout << " " << years[row][col] << " ";
    }
  }
}
cout << "\n\n";
system("PAUSE");
}


Occurrence of a Number in C++

Here is a sample program that I wrote a very long time ago while I am teaching in one of the university in Bacolod City, Negros Occidental Philippines in my C++ class. This program will count the occurrence of the number.  I am using CodeBlocks as my text editor and Dev C++ as my C++ compiler in this sample program. I hope you will find my work useful. Thank you.

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

My mobile number here in the Philippines is 09173084360.



Program Listing


#include <iostream>

using namespace std;


main(void) {
 int items[5];
    int search=0;
    int occur=0,x=0;


    for (int x=0; x<5; x++) {
        cout << "Enter Item No."
            << x+1 << " : ";
        cin >> x[items];
    }

     cout << "\n\n";
     cout <<"Enter Item to search :";
     cin >> search;
    for (x=0; x<5; x++) {
     if (search == x[items]) {
         occur++;

     }

    }
 cout << "\n\n";
     cout << "Number occurence of is "
         << occur << ".";

    if (search != x[items]) {
         cout << "Not Found in the List.";

     }


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

Divide Two Numbers in Turbo Pascal

Here is a sample program that will ask the user to give two numbers and then our program will compute for it's quotient. I am using a user defined function in Turbo Pascal. I hope you will find my work useful. Thank you.

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

My mobile number here in the Philippines is 09173084360.





Sample Program Output


Program Listing

Program divide_two_numbers;
Uses Crt;

Var c,d,results : real;


Function Divide(a,b : real) : real;
begin
  divide := (a/b);
end;

Begin
  Clrscr;
  Writeln;
  textcolor(White);
  Write('Divide Two Numbers in Turbo Pascal');
  Writeln;
  Writeln;
  Write('Enter First Number  : ');
  Readln(c);
  Writeln;
  Write('Enter Second Number : ');
  Readln(d);

  results := Divide(c,d);

  Writeln;
  Writeln;
  Write('The quotient of ',c:5:2, ' and ',d:5:2, ' is ' ,results:5:2, '.');
  Writeln;
  Writeln;
  Write('End of Program');
  Writeln;
  Readln;
End.



Upper Case String Converter in Turbo Pascal

Here is a sample program that I wrote using Turbo Pascal 6 For DOS to ask the users name and then our program will convert the given users name into upper case letters. The code is very easy to understand and use. Thank you.

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

My mobile number here in the Philippines is 09173084360.






Sample Program Output


Program Listing

Program Upper_Case_Convert;
Uses Crt;

Var User_Name,Result : String;


Function StringUpper(s:String):String; 
var 
i:byte; 
begin 
  for i:=1 to length(s) do s[i]:=Upcase(s[i]); 
  StringUpper := s; 
end; 

Begin
  Clrscr;
  Writeln;
  textcolor(White);
  Write('Upper Case Converter in Turbo Pascal');
  Writeln;
  Writeln;
  Write('Enter you Name : ');
  Readln(User_Name);

  Result := StringUpper(User_Name);

  Writeln;
  Writeln;
  Write(' Hello ' ,Result,'.');
  Writeln;
  Writeln;
  Write('End of Program');
  Writeln;
  Readln;
End.




Area of the Square in Visual Foxpro


Here is a sample program that will ask the user to give a length of the side of the square and then the program will compute for the area of the square. I wrote this sample program using Microsoft Visual Foxpro 5.0. I hope you will find my work useful. Thank you.

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

My mobile number here in the Philippines is 09173084360.





Sample Program Output



Program Listing


Ok Button   Command1  Click

set decimal to 2
SET FIXED ON

clear

side = val(thisform.text1.value) 
area_square = (side * side);

final_solve= round(area_square,2)

thisform.label4.caption = "The area of the square is " + alltrim(thisform.text3.value)


thisform.text3.value =  final_solve

Clear Button  Command2  Click

thisform.text1.value=""
thisform.text3.value=""
thisform.text1.setfocus
thisform.label4.caption =""


Quit Button Command2  Click

Quit

Area of the Circle in Visual Foxpro

Here is a sample program that will ask the user to give a value in radius and then the program will compute for the area of the circle. I wrote this sample program using Microsoft Visual Foxpro 5.0. I hope you will find my work useful. Thank you.

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

My mobile number here in the Philippines is 09173084360.






Sample Program Output


Program Listing

Ok Button   Command1  Click

set decimal to 2
SET FIXED ON

clear

radius = val(thisform.text1.value) 
area = (3.1416 * radius * radius);

final_solve= round(area,2)

thisform.label4.caption = "The area of the circle is " + alltrim(thisform.text3.value)


thisform.text3.value =  final_solve


Clear Button  Command2  Click

thisform.text1.value=""
thisform.text3.value=""
thisform.text1.setfocus
thisform.label4.caption =""


Quit Button Command2  Click

Quit


Sunday, April 23, 2017

Payroll Program in Visual Foxpro

A very simple payroll program that I wrote using Microsoft Visual Foxpro to accept the employees number of days worked and the rate per day and then our program will compute its salary. The code is very basic and easy to understand I am using Microsoft Visual Foxpro 5.0 in writing this program. Thank you.


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

My mobile number here in the Philippines is 09173084360.







Sample Program Output


Program Listing


Ok Button   Command1  Click

set decimal to 2
SET FIXED ON

clear
days_worked = val(thisform.text1.value) 

rate_per_day = val(thisform.text2.value) 

solve_salary = (days_worked) * (rate_per_day)

final_solve= round(solve_salary,2)
thisform.label4.caption = "Your salary is Php " + alltrim(thisform.text3.value)


thisform.text3.value =  final_solve


Clear Button  Command2  Click

thisform.text1.value=""
thisform.text2.value=""
thisform.text3.value=""
thisform.text1.setfocus
thisform.label4.caption =""


Quit Button Command2  Click

Quit


Product of Two Numbers in Visual Foxpro

A very simple program that I wrote using Microsoft Visual Foxpro to ask the user to give two numbers and then our program will compute the product of two numbers given by the user. I wrote this code using Microsoft Visual Foxpro 5.0. Thank you.

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

My mobile number here in the Philippines is 09173084360.





Sample Program Output



Program Listing

Ok Button   Command1  Click

number_val_1 = val(thisform.text1.value) 

number_val_2 = val(thisform.text2.value) 

solve_product = (number_val_1) * (number_val_2)

thisform.label4.caption = "The product of " + alltrim(str(number_val_1)) + " and " + alltrim(str(number_val_2)) + " is " + alltrim(str(solve_product)) + "."


Clear Button  Command2  Click

thisform.text1.value=""
thisform.text2.value=""
thisform.text1.setfocus
thisform.label4.caption =""


Quit Button Command2  Click

Quit


Positive and Negative Number Checker in Visual Foxpro

Here is a very simple program that I wrote using Microsoft Visual Foxpro to ask the user to give a number and then our program will check and determine if the given number is a POSITIVE or NEGATIVE number based on the given number by our user. The version of Visual Foxpro that I am using in this sample program is 5.0. Thank you.

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

My mobile number here in the Philippines is 09173084360.







Sample Program Output


Program Listing

Ok Button   Command1  Click

number_val = val(thisform.text1.value) 

if (number_val >= 0) then
   MESSAGEBOX("The given number is a POSITIVE number.",0,"The Result")
   thisform.text1.value=""
   thisform.text1.setfocus
  else
   MESSAGEBOX("The given number is an NEGATIVE number.",0,"The Result")
   thisform.text1.value=""
   thisform.text1.setfocus
endif   


Clear Button  Command2  Click

thisform.text1.value=""
thisform.text1.setfocus


Quit Button Command2  Click

Quit