Sunday, April 10, 2016

Miles To Kilometers Converter in Visual Basic.NET

A very simple program that I wrote in Visual Basic.NET that will ask the user to give the distance in Miles and then our program will convert the given distance by the user in Miles to Kilometers.

Add me at Facebook my address is 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 Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Label3.Visible = False
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Label3.Visible = True

        Dim Miles As Decimal

        Dim Kilometers As Decimal

        Miles = Val(TextBox1.Text)

        Kilometers = (Miles * 1.609344)

        Label3.Text = Miles & " Mile(s) is equivalent to " & Math.Round(Kilometers, 2) & " Kilometer(s)"


    End Sub

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




Fahrenheit To Celsius Converter in Visual Basic.NET Version 2

Here is the second version of my program that I wrote before in Visual Basic.NET Fahrenheit to Celsius Converter in Visual Basic.NET the code is very simple and easy to understand.


Add me at Facebook my address is 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 Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Label3.Visible = False
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Label3.Visible = True

        Dim F As Decimal

        Dim C As Decimal

        C = Val(TextBox1.Text)

        F = C * 1.8 + 32
        Label3.Text = "The temperature in Celsius is " & F & Chr(176) & "C"

    End Sub

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

Addition of Two Numbers in Visual Basic.NET

A simple program that I wrote using Visual Basic.NET to add the sum of two numbers. I'm just learning Visual Basic.NET primarily because my experience before in programming in using Visual Basic 6 it is a good learning experience on my part.


Add me at Facebook my address is 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 Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim sum As Integer
        Dim a As Integer
        Dim b As Integer

        Label4.Visible = True

        If TextBox1.Text = "" Then
            Label4.Visible = False
            MessageBox.Show("Sorry cannot be empty.")
            TextBox1.Focus()
        End If

        a = Val(TextBox1.Text)
        b = Val(TextBox2.Text)
        sum = (a + b)

        Label4.Text = "The sum of " & a & " and " & b & " is " & sum & "."

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Label4.Visible = False


    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
        Label4.Text = ""

        TextBox1.Focus()
    End Sub
End Class






Saturday, April 9, 2016

Switch and Boolean Statement in C++

Here is a sample program that I wrote a long time ago that demonstrate the use of switch and Boolean statements in C++ language that will check if the age of the person is still a minor or adult already.

Add me at Facebook my address is 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 a=0;
      
      cout << "Enter a your age : ";
      cin >> a;
      
      switch(a >= 18 ? true : false)
      {
               case true : cout << "Your are Adult.";
                                break;
               case false  : cout << "Sorry you are still Minor.";
         }
      cout << "\n\n";
      system("pause");
      }
      




Postfix To Prefix in Converter in C

A simple program that will convert a given expression by the user in postfix and then it will convert it into prefix equivalent in C programming language.


Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Program Listing



#include <stdio.h>
#include <conio.h>
#include <string.h>

#define MAX 100

struct postfix
{
char stack[MAX][MAX], target[MAX] ;
char temp1[2], temp2[2] ;
char str1[MAX], str2[MAX], str3[MAX] ;
int i, top ;
} ;

void initpostfix ( struct postfix * ) ;
void setexpr ( struct postfix *, char * ) ;
void push ( struct postfix *, char * ) ;
void pop ( struct postfix *, char * ) ;
void convert ( struct postfix * ) ;
void show ( struct postfix ) ;

void main( )
{
struct postfix q ;
char expr[MAX] ;

clrscr( ) ;

initpostfix ( &q ) ;
     
        printf ( "\n POSTFIX TO PREFIX CONVERTER IN C " ) ;
        printf("\n\n");
printf ( "\nEnter an expression in postfix form: " ) ;
gets ( expr ) ;

setexpr ( &q, expr ) ;
convert ( &q ) ;

printf ( "\nThe Prefix expression is: " ) ;
show ( q ) ;

getch( ) ;
}


void initpostfix ( struct postfix *p )
{
p -> i = 0 ;
p -> top = -1 ;
strcpy ( p -> target, "" ) ;
}


void setexpr ( struct postfix *p, char *c )
{
strcpy ( p -> target, c ) ;
}


void push ( struct postfix *p, char *str )
{
if ( p -> top == MAX - 1 )
printf ( "\nStack is full." ) ;
else
{
p -> top++ ;
strcpy ( p -> stack[p -> top], str ) ;
}
}

void pop ( struct postfix *p, char *a )
{
if ( p -> top == -1 )
printf ( "\nStack  is empty." ) ;
else
{
strcpy ( a, p -> stack[p -> top] ) ;
p -> top-- ;
}
}


void convert ( struct postfix *p )
{
while ( p -> target[p -> i] != '\0' )
{
/* skip whitespace, if any */
if ( p -> target[p -> i] == ' ')
p -> i++ ;
if( p -> target[p -> i] == '%' || p -> target[p -> i] == '*' ||
p -> target[p -> i] == '-' || p -> target[p -> i] == '+' ||
p -> target[p -> i] == '/' || p -> target[p -> i] == '$' )
{
pop ( p, p -> str2 ) ;
pop ( p, p -> str3 ) ;
p -> temp1[0] = p -> target[ p -> i] ;
p -> temp1[1] = '\0' ;
strcpy ( p -> str1, p -> temp1 ) ;
strcat ( p -> str1, p -> str3 ) ;
strcat ( p -> str1, p -> str2 ) ;
push ( p, p -> str1 ) ;
}
else
{
p -> temp1[0] = p -> target[p -> i] ;
p -> temp1[1] = '\0' ;
strcpy ( p -> temp2, p -> temp1 ) ;
push ( p, p -> temp2 ) ;
}
p -> i++ ;
}
}


void show ( struct postfix p )
{
char *temp = p.stack[0] ;
while ( *temp )
{
printf ( "%c ", *temp ) ;
temp++ ;
}

}

Descending Numbers in C

Here is a sample program that I wrote a very long time a ago in C language that will ask a series of numbers and then it will sort the given numbers into descending order.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Program Listing

#include <stdio.h>
#include <conio.h>

int main()
{
     int arr[100],i,j,element,no,temp;
     clrscr();
     printf("\nEnter the no of Elements: ");
     scanf("%d", &no);
     for(i=0;i<no;i++){
          printf("\n Enter Element %d: ", i+1);
          scanf("%d",&arr[i]);
     }
     for(i=0;i<no;i++){
          for(j=i;j<no;j++){
               if(arr[i] < arr[j]){
               temp=arr[i];
               arr[i]=arr[j];
               arr[j]=temp;
               }
           }
     }
     printf("\nSorted array:");
     for(i=0;i<no;i++){
          printf("\t%d",arr[i]);
     }
     getch();
}





Decimal To Hexadecimal in Python


A simple program that I wrote using Python programming language that will ask the user to give decimal number and then our program will convert the given number into its hexadecimal equivalent.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

def my_program():
   print()
   print("DECIMAL TO HEXADECIMAL CONVERTER")
   print()
   decimal = int(input("Enter a Number: "))
   print()
   print('The number {0} in Decimal is equivalent to '.format(decimal))
   print(hex(decimal), " in Hexadecimal.");
   print("\n");
   repeat = input('Do you want to continue ? (Y/N) : ')

   if repeat.upper() == "N":
       print("\n")
       print("END OF PROGRAM")
       quit
   if repeat.upper() == "Y":
       my_program()

if __name__ == '__main__':
       my_program()


Decimal To Octal Converter in Python

A simple program that I wrote using Python programming language that will ask the user to give decimal number and then our program will convert the given number into its octal equivalent.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

def my_program():
   print()
   print("DECIMAL TO OCTAL CONVERTER")
   print()
   decimal = int(input("Enter a Number: "))
   print()
   print('The number {0} in Decimal is equivalent to '.format(decimal))
   print(oct(decimal), " in octal.");
   print("\n");
   repeat = input('Do you want to continue ? (Y/N) : ')

   if repeat.upper() == "N":
       print("\n")
       print("END OF PROGRAM")
       quit
   if repeat.upper() == "Y":
       my_program()

if __name__ == '__main__':
       my_program()



Decimal To Binary Converter in Python

A simple program that I wrote using Python programming language that will ask the user to give decimal number and then our program will convert the given number into its binary equivalent.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output

Program Listing

def convert_binary(values):
   
   if values > 1:
     convert_binary(values//2)
   print(values % 2,end = '')

def my_program():
   print()
   print("DECIMAL TO BINARY CONVERTER")
   print()
   decimal = int(input("Enter a Number: "))
   print()
   print('The number {0} in Decimal is equivalent to '.format(decimal))
   convert_binary(decimal);
   print(" in binary.");
   print("\n");
   repeat = input('Do you want to continue ? (Y/N) : ')

   if repeat.upper() == "N":
       print("\n")
       print("END OF PROGRAM")
       quit
   if repeat.upper() == "Y":
       my_program()

if __name__ == '__main__':
       my_program()


Kilometers To Miles Converter in Python

In this simple program it will ask the user to give the distance in kilometers and then our program will convert the given distance in miles into kilometers equivalent using Python as my programming language.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

def my_program():
   print()
   print("KILOMETERS TO MILES CONVERTER")
   print()
   kilometers = float(input("How many kilometer(s) ? : "))
   print()
   miles = (kilometers *  0.621371)
   print('%0.2f Kilometers(s) is equal to %0.2f Mile(s).' %(kilometers,miles))
   print("\n");
   repeat = input('Do you want to continue ? (Y/N) : ')

   if repeat.upper() == "N":
       print("\n")
       print("END OF PROGRAM")
       quit
   if repeat.upper() == "Y":
       my_program()

if __name__ == '__main__':
       my_program()





Miles To Kilometers Converter in Python

In this simple program it will ask the user to give the distance in Miles and then our program will convert the given distance in miles into kilometers equivalent using Python as my programming language.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

def my_program():
   print()
   print("MILES TO KILOMETERS CONVERTER")
   print()
   miles = float(input("How many miles? : "))
   print()
   kilometers = (miles * 1.60934)
   print('%0.2f Mile(s) is equal to %0.2f Kilometer(s).' %(miles,kilometers))
   print("\n");
   repeat = input('Do you want to continue ? (Y/N) : ')

   if repeat.upper() == "N":
       print("\n")
       print("END OF PROGRAM")
       quit
   if repeat.upper() == "Y":
       my_program()

if __name__ == '__main__':
       my_program()


Cube Numbers in Python

A simple program that I wrote using Python as my programming language that will ask the user to give a number and then our program will convert the give number by the user into cube number equivalent.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing


def my_program():
   print()
   print("CUBE NUMBERS PROGRAM")
   print()
   number = int(input("Enter a Number : "))
   print()
   solve_cube = (number * number * number)
   print("The cube value of ",number, " is "
          ,solve_cube,".")
   print("\n");
   repeat = input('Do you want to continue ? (Y/N) : ')

   if repeat.upper() == "N":
       print("\n")
       print("END OF PROGRAM")
       quit
   if repeat.upper() == "Y":
       my_program()

if __name__ == '__main__':
       my_program()