Wednesday, June 14, 2017

Decimal To Roman Numeral in VB.NET

Here a sample program that I wrote in VB.NET to accept a decimal input value and then it will convert it to roman numeral equivalent the code is very simple and easy to understand. I hope you will learn from it. 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 ConvertToRoman(ByVal input As Integer) As String
        Dim numeral As String = String.Empty

        If input < 1 OrElse input > 4000 Then

            Throw New ArgumentOutOfRangeException("input", input.ToString, "Value must be greater than 0 and less than 4,001.")
        Else

            Dim numeralDic As Dictionary(Of Integer, String) = New Dictionary(Of Integer, String)
            With numeralDic
                .Add(1, "I")
                .Add(4, "IV")
                .Add(5, "V")
                .Add(9, "IX")
                .Add(10, "X")
                .Add(40, "XL")
                .Add(50, "L")
                .Add(90, "XC")
                .Add(100, "C")
                .Add(400, "CD")
                .Add(500, "D")
                .Add(900, "CM")
            End With


            For x As Integer = 0 To input.ToString.Length - 1
                Dim currentValue As Integer = CInt(input.ToString.Substring(x, 1))

                If x = input.ToString.Length - 1 Then

                    If numeralDic.ContainsKey(currentValue) Then

                        numeral &= numeralDic(currentValue)
                    ElseIf currentValue < 4 Then
                    
                        For y As Integer = 1 To currentValue
                            numeral &= "I"
                        Next
                    ElseIf currentValue > 5 Then

                        numeral &= "V"
                        For y As Integer = 6 To currentValue
                            numeral &= "I"
                        Next
                    End If
                ElseIf x = input.ToString.Length - 2 Then
                   
                    currentValue = currentValue * 10
                    If numeralDic.ContainsKey(currentValue) Then
                        numeral &= numeralDic(currentValue)
                    ElseIf currentValue < 4 Then
                        For y As Integer = 1 To currentValue
                            numeral &= "X"
                        Next
                    ElseIf currentValue > 5 Then
                        numeral &= "L"
                        For y As Integer = 6 To currentValue
                            numeral &= "X"
                        Next
                    End If
                ElseIf x = input.ToString.Length - 3 Then
                    currentValue = currentValue * 100
                    If numeralDic.ContainsKey(currentValue) Then
                        numeral &= numeralDic(currentValue)
                    ElseIf currentValue < 4 Then
                        For y As Integer = 1 To currentValue
                            numeral &= "C"
                        Next
                    ElseIf currentValue > 5 Then
                        numeral &= "D"
                        For y As Integer = 6 To currentValue
                            numeral &= "C"
                        Next
                    End If
                Else

                    For y As Integer = 1 To currentValue
                        numeral &= "M"
                    Next
                End If
            Next
        End If


        Return numeral
    End Function
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


    End Sub

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

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label3.Text = "The Roman Numeral Equivalent of " & Val(TextBox1.Text) & " is " & ConvertToRoman(Val(TextBox1.Text)) & "."


    End Sub

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

    End Sub
End Class


Monday, June 12, 2017

Decimal To Roman Numeral Converter in Java

In this article I would like to share with you a simple program that will ask the user to give a year and then our program will convert the given year into roman numeral equivalent using Java. 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

// Written By: Mr. Jake R. Pomperada, MAED-IT
// Date : June 12, 2017  Monday 2:41 PM
// Language: Java
// Place of Origin:  Mandaluyong City, Metro Manila Philippines.


package demo;


import java.util.Scanner;

class roman {
public int a;
public int num,th,h,t,u;
 
String thou[]={"","M","MM","MMM"};
String hund[]={"","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"};
String ten[]={"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"};
String unit[]={"","I","II","III","IV","V","VI","VII","VIII","IX"};

public void setA(int a) {
this.a = a;
}

public int getA() {
return a;
}
public void displayResult(int num)
{
this.num = num;
th=num/1000;
h=(num/100)%10;
t=(num/10)%10;
u=num%10;
System.out.println();
System.out.println("The given is " + num + ".");
System.out.println();
System.out.println("The Roman Numeral  Equivalent is  "+thou[th]+hund[h]+ten[t]+unit[u] + ".");
System.out.println();
   System.out.print("\t END OF PROGRAM");
System.out.println();
}

public static void main(String[] args) {

Scanner input = new Scanner(System.in);
     roman val = new roman(); 
  
      System.out.println();
      System.out.println("Decimal To Roman Numeral Converter Using Getters and Setters");
      System.out.println();
      System.out.print("Enter first value : ");
      val.a = input.nextInt();
      
       val.setA(val.a);
   val.getA();

   val.displayResult(val.a);
   
       input.close();
}

}




Sunday, June 11, 2017

Sum of Two in Java Using Getters and Setters

In this article I would like to share with you a sample program that I wrote in Java to ask the user to give two numbers and then our program will compute the sum of two numbers using getters and setters in Java. The code is very simple and easy to understand the concepts of Object Oriented Programming in Java. 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

SumTwo.java

// Written By: Mr. Jake R. Pomperada, MAED-IT
// Date : June 11, 2017  Sunday 12:07 AM
// Language: Java
// Place of Origin:  Mandaluyong City, Metro Manila Philippines.


package demo;

import java.util.Scanner;

class SumTwo {
public int a;
public int b;

public void setA(int a) {
this.a = a;
}
public void setB(int b) {
this.b = b;
}
public int getA() {
return a;
}
public int getB() {
return b;
}
public int getSum()
{
return(a+b);
}

public static void main(String[] args) {

Scanner input = new Scanner(System.in);
SumTwo val = new SumTwo(); 
  
      System.out.println();
      System.out.println("Sum of Two in Java Using Getters and Setters");
      System.out.println();
      System.out.print("Enter first value : ");
      val.a = input.nextInt();
      System.out.print("Enter second value : ");
      val.b = input.nextInt();

       val.setA(val.a);
   val.setB(val.b);
   val.getA();
   val.getB();
   val.getSum();
   
   System.out.println();
       System.out.print("The sum of " +val.a + " and " + val.b + " is " + val.getSum() + ".");
       System.out.println("\n");
       System.out.print("\t END OF PROGRAM");
       input.close();
}

}







Saturday, June 10, 2017

Hello World in TypeScript

Hi there I would like to share with you a sample program that I wrote using TypeScript a JavaScript Framework in this sample program it will display hello world with my name in the web page. I am still learning TypeScript during the writing of this code.  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

hello.ts

class Hello {
    constructor (public msg: string){
    }
    sayHello() {
        return "<h2>" + this.msg + "</h2>";
    }
};
var hello = new Hello("Hello World, What do you think of TypeScript Mr. Jake R. Pomperada? ");

document.body.innerHTML = hello.sayHello();

hello.js

var Hello = (function () {
    function Hello(msg) {
        this.msg = msg;
    }
    Hello.prototype.sayHello = function () {
        return "<h2>" + this.msg + "</h2>";
    };
    return Hello;
}());
;
var hello = new Hello("Hello World, What do you think of TypeScript Mr. Jake R. Pomperada? ");

document.body.innerHTML = hello.sayHello();

hello.htm

<!DOCTYPE html>
<html>
  <head><title>TypeScript Hello World | Mr. Jake R. Pomperada </title></head>
  <body>
    <script src='hello.js'></script>
  </body>
</html>


Sunday, June 4, 2017

Square a Number in Python

A very simple program that I wrote using Python to ask the user to give a number and then our program will compute the square equivalent of the given number by the user.

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

square.py

print("\n")
print("Square a Number in Python")
print("\n")
num = int(input("Enter a number: "))
square = num * num
print("\n")
print("The square value of {0} is the number is {1} ".format(num,square))
print("\n")
print("End of Program")

Product of Two Numbers in Fortran

Here is a sample program that will ask the user to give two numbers and then our program will compute the product of the two numbers using FORTRAN as our programming language.

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 product                                      
         
    integer :: solve_product,x,y
    
    print  *, ''   
    print  *, 'Product of Two Numbers in Fortran'
    print  *, ''                                      
  print  *, 'Enter two numbers'                       
  read  *, x,y                                          
                                   
  solve_product=x*y   
    print  *, ''                                          
  print  *, 'The product of ',x, ' and ',y, ' is ' ,solve_product,'.'  
    print  *, ''     
    print  *, 'End of Program'                        
end  program product                                   
  

Addition of Two Numbers in FORTRAN

Here is a very simple program that I wrote in FORTRAN that will accept two numbers and then it will compute and display the sum of the two numbers. The code is very easy to understand and use. You may download the FORTRAN compiler free from charge in this link http://www.fortran.com/the-fortran-company-homepage/whats-new/g95-windows-download/

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

add.f95

program add

implicit none

integer a,b,sum

print *,''
print *, ' Addition of Two Numbers in Fortran'
print *,''
print *,' Written By: Mr. Jake R. Pomperada'
print *,''
print *, ' Enter Two Numbers : '
read *, a,b
sum = a + b
print *,''
print *, ' The sum of ', a,' and ' , b, ' is ' , sum,'.'
print *,''
print *,'End of Program'
end program

Hello World in FORTRAN

Hi guys in this article I would like to share with you my very first program written in FORTRAN or Formula Translator it is a Hello World program. The code is very short and easy to understand. I am using G95 Fortran Compiler that is also FREE to download at the Internet. Kindly see the link here http://www.fortran.com/the-fortran-company-homepage/whats-new/g95-windows-download/

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

hello.f95

 program hello 
 print *,"Hello World Jake R. Pomperada" 
 end program 



Saturday, June 3, 2017

Palindrome in Visual Basic 6

In this article I would like to share with you a simple program that will ask the user to give a string and then our program will check if the given string is a palindrome or not a palindrome.

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

Private Sub Command1_Click()

display1 = "The given string " & Trim(UCase(Text1.Text)) & " is a Palindrome."
display2 = "The given string " & Trim(UCase(Text1.Text)) & " is Not a Palindrome."

If IsPalindromeStrict(Text1.Text) = True Then
    MsgBox (display1)
  Else
     MsgBox (display2)
End If

End Sub


Public Function IsPalindromeStrict(pstrText As String) As Boolean
    Dim i As Long
    Dim iMin As Long
    Dim iMax As Long
    
    iMin = 1
    iMax = Len(pstrText)
    For i = 0 To (iMax - iMin) \ 2
        If Mid$(pstrText, iMin + i, 1) <> Mid$(pstrText, iMax - i, 1) Then Exit Function
    Next
    IsPalindromeStrict = True
End Function
 

Public Function IsPalindrome(ByVal pstrText As String) As Boolean
    Dim i As Long
    Dim iMin As Long
    Dim iMax As Long
    
    pstrText = LCase$(pstrText)
    
    i = 1
    Do
        Select Case Mid$(pstrText, i, 1)
            Case "a" To "z", "0" To "9": i = i + 1
            Case Else: pstrText = Replace(pstrText, Mid$(pstrText, i, 1), vbNullString)
        End Select
    Loop While i <= Len(pstrText)
    
    iMin = 1
    iMax = Len(pstrText)
    For i = 0 To (iMax - iMin) \ 2
        If Mid$(pstrText, iMin + i, 1) <> Mid$(pstrText, iMax - i, 1) Then Exit Function
    Next
    IsPalindrome = True
End Function

Private Sub Command2_Click()
End
End Sub


Friday, June 2, 2017

Yard To Feet Converter in C++

Here is a simple program that I wrote in C++ to ask the user to give a value in integer in yard and convert it to feet equivalent. I wrote this code using Dev C++ and CodeBlocks. 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>
#include <iomanip>

using namespace std;

main() {
    int yards[5][1];

    cout << "\t\t    Yard To Feet Converter";
    cout << "\n";
    cout << "\t Created By: Mr. Jake R. Pomperada,MAED-IT";
    cout << "\n\n";

       for (int row=0; row < 5; row++) {
           for (int col=0; col <1; col++) {
               cout << "Enter a Value in Yard :=> ";
               cin >> yards[row][col];
           }
       }

       cout << "\n=============================";
       cout << "\n      GENERATED REPORT     ";
       cout << "\n=============================";
       cout << "\n";
       for (int row=0; row < 5; row++) {
           for (int col=0; col <1; col++) {
                 cout << "\n" <<setw(5) <<  yards[row][col] <<
                 " yard(s)" << setw(5)  << " ==> "
                 << (yards[row][col] * 3)
                 << " feet(s)";
                  }

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

Three Attempts Login System in C++

A very simple program that I wrote using C++ which allows the user to login in the system it gives the user three times to login successfully in the system. I am using CodeBlocks as my text editor and Dev C++ as my C++ compiler in writing and testing 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

#include <iostream>
#include <string>

using namespace std;

int main()
{

    string password = "admin";
    string passwordEntry;
    int attempts = 1;

    cout << "THREE ATTEMPTS LOGIN SYSTEM";
    cout <<"\n\n";
    cout << "Enter your password: ";
    getline(cin, passwordEntry, '\n');

    while ( passwordEntry != password && attempts <=2 )
    {
        cout << "\n";
        cout <<"Password Attempt No. : " <<attempts+1;
        cout << "\n";
        cout << "Enter Password Again : ";
        getline(cin, passwordEntry, '\n');
        attempts++;
    }

    if ( passwordEntry == password && attempts <=3 )
    {
        cout << "\n";
        cout << "Access Granted in the System.";
    }
    else
    {
        cout << "\n";
        cout << "Sorry, you are only allowed 3 password login attempts.";
        cout << "\n\n";
    }

}