Sunday, January 15, 2017

Consonants and Vowels in Visual Basic NET


Here is another simple program that I wrote using Visual Basic NET that will ask the user to give a string and then our program will count the number of consonants and vowels in the given string by our user. In this program I am using Microsoft Visual Studio Ultimate 2012 Edition. I hope you will find my work useful. Thank you.

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

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

    Const vowels = "aeiou"

    Const consonants = "bcdfghjklmnpqrstvwzyz"


    Private Function Count_All_Vowels(given_string As String) As Integer
        Dim i As Integer
        For i = 1 To Len(given_string)
            If InStr(1, vowels, Mid$(given_string, i, 1), vbTextCompare) Then
                Count_All_Vowels = Count_All_Vowels + 1
            End If
        Next i
        Return Count_All_Vowels
    End Function

    Private Function Count_All_Consonants(given_string As String) As Integer
        Dim i As Integer
        For i = 1 To Len(given_string)
            If InStr(1, consonants, Mid$(given_string, i, 1), vbTextCompare) Then
                Count_All_Consonants = Count_All_Consonants + 1
            End If
        Next i
        Return Count_All_Consonants
    End Function


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Label2.Text = "The Number of Vowels is " & Count_All_Vowels(UCase(TextBox1.Text)) & "."
        Label3.Text = "The Number of Consonants is " & Count_All_Consonants(UCase(TextBox1.Text)) & "."
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        End
    End Sub
End Class




Count Vowels in Visual Basic NET

Here is a simple program that I wrote using Visual Basic NET to ask the user to give a string and then our program will count the number of vowels in the given string. The code is very short and easy to understand.

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

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

    Const vowels = "aeiou"


    Private Function Count_All_Vowels(given_string As String) As Integer
        Dim i As Integer
        For i = 1 To Len(given_string)
            If InStr(1, vowels, Mid$(given_string, i, 1), vbTextCompare) Then
                Count_All_Vowels = Count_All_Vowels + 1
            End If
        Next i
        Return Count_All_Vowels
    End Function


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Label2.Text = "The Number of Vowels is " & Count_All_Vowels(UCase(TextBox1.Text)) & "."
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        End
    End Sub
End Class

Monday, January 9, 2017

Count Positive and Negative Numbers in C++

I this article I would like to share with you a sample program that will ask the user to give a series of positive and negative numbers and then our program will count how many positive and negative numbers being given by our user using array in C++. I wrote this code almost 7 years ago while I am teaching C++ programming in the university that I am working with. I hope you will find my work useful. Thank you.

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

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 grades[5],positive=0,negative=0;

   for (int list=0; list <5; list+=1) {
       cout << "Enter value No " << list+1 << ":";
       cin >> list[grades];
   }
   cout << "\n\n";
   for (int list=0; list <5; list+=1) {

      if (list[grades] >= 0) {
           positive++;
   }
   else {
       negative++;
   }
}
   cout << "\n\n";
   cout << "\nNumber of Positive Number : " << positive;
   cout << "\nNumber of Negative Number : " << negative;
   cout << "\n\n";
       system("PAUSE");
}

Scanner Class in Java

In this article I would like to share with you a sample program that I wrote using Java as my programming language to ask the users name and age and then our program will greet our user and display the users name user scanner class to accept input from our user. The code is very short and easy to understand.

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

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

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication1;

import java.util.Scanner;

/**
 *
 * @author Jacob pomperada
 * Example of Scanner Class in Java
 * January 9, 2017 Monday
 */


public class JavaApplication1 {
    
  public static void main(String args[]) {
    
   Scanner input=new Scanner(System.in);  
   
   System.out.print("\t Scanner Class Demo in Java ");  
   System.out.println("\n");
   System.out.print("Enter your Name : ");  
   String user =input.nextLine();  
   System.out.print("Enter your Age :");  
   int age=input.nextInt();  
   
   System.out.println();
   System.out.print("Hi " + user + " Your age is " + age +" years old.");
   System.out.println("\n");
   System.out.println("\t End of Program");
   System.out.println();
   }

}




Inner Class in Java

Happy New Year To All my visitors and friends who visited my website. I has been a while since I was able to post new sample program in my website because of my hectic schedule. Anyway in this article I would like to share with you a sample program that I wrote in Java to demonstrate how inner class works in Java programming language. The code is very simple just to demonstrate how it works.

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

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

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication1;

/**
 *
 * @author Jacob pomperada
 * Example of Inner Class in Java
 * January 9, 2017 Monday
 */
class Outer_Class_Demo {
    
   // inner class
   private class Inner_Demo {
      public void display_result() {
         System.out.println("\n");
         System.out.print("\t Inner Class in Java Example");
         System.out.println("\n");
         System.out.println("This is an inner class demonstration in Java");
         System.out.println();
         System.out.println("End of Program");
         System.out.println();
         
      }
   }
   
      void Display_Inner_Class() {
      Inner_Demo inner_class = new Inner_Demo();
      inner_class.display_result();
   }
}  


public class JavaApplication1 {
    
  public static void main(String args[]) {
      
      Outer_Class_Demo outer_class_demo = new Outer_Class_Demo();
         
      outer_class_demo.Display_Inner_Class();
   }

}





Saturday, December 17, 2016

Square and Cube Number Solver in C# Using Methods

Here is a sample program that I wrote using Microsoft C# programming language that will ask the user to give a number and then our program will compute the square and cube equivalent of the given number by our user.

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

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

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

/* Square and Cube Number Solver Using Methods        */
/* Author : Mr. Jake R. Pomperada, MAED-IT           */
/* Date   : December 3, 2016    Saturday 10:42 AM    */
/* Tool   : C#                                      */


namespace square_cube_number
{
    class square_cube_number
    {

        // Method Square a Number
        static public int square_number(int a)
        {
            return a * a;

        }

        // Method Cube a Number
        static public int cube_number(int a)
        {
            return a * a * a;

        }
        static void Main(string[] args)
        {
            int val_1 = 0;
            int solve_square = 0;
            int solve_cube = 0;

            Console.Write("\n\n");
            Console.Write("\t SQUARE AND CUBE NUMBER SOLVER USING METHODS ");
            Console.Write("\n\n");
            Console.Write("Give a Number :  ");
            val_1 = Convert.ToInt32(Console.ReadLine());

            solve_square = square_number(val_1);
            solve_cube = cube_number(val_1);
            
            Console.Write("\n\n");
            Console.Write("The given number is {0} it's square equivalent is {1}." ,val_1,solve_square);
            Console.Write("\n\n");
            Console.Write("The given number is {0} it's cube equivalent is {1}.", val_1, solve_cube);
            Console.Write("\n\n\n");
            Console.Write("Thank You For Using This Software.");
            Console.Write("\n\n");
            Console.ReadLine();
        }
    }
}






Area of the Circle in Visual Basic NET

Here is another simple program that I wrote using Microsoft Visual Basic NET to ask the user to give the radius of the circle and then our program will compute it's area based on the given radius value of the user.

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

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 Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim compute_area_circle As Double
        compute_area_circle = (Val(TextBox1.Text) * Val(TextBox1.Text) * 3.1416)
        Label4.Text = "The Area of the Circle is " & Format(compute_area_circle, "0.00")
    End Sub

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

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim result As DialogResult = MessageBox.Show("Do you want to quit?", _
                               "Quit Program", _
                               MessageBoxButtons.YesNo)

        If (result = DialogResult.Yes) Then
            End
        Else
            TextBox1.Text = ""
            Label4.Text = ""
            TextBox1.Focus()
        End If
    End Sub

    
End Class





Inches To Centimeter Converter in Visual Basic NET

In this simple program it will ask the user to give value in inches and then our program will convert the given value into centimeters equivalent using Microsoft Visual Basic NET. The code is design for beginners like me in Visual Basic NET programming.

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

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 Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim compute_centimeter As Double
        compute_centimeter = (Val(TextBox1.Text) * 2.54)
        Label4.Text = "The Centimeter Equivalent is " & Format(compute_centimeter, "0.00")
    End Sub

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

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim result As DialogResult = MessageBox.Show("Do you want to quit?", _
                               "Quit Program", _
                               MessageBoxButtons.YesNo)

        If (result = DialogResult.Yes) Then
            End
        Else
            TextBox1.Text = ""
            Label4.Text = ""
            TextBox1.Focus()
        End If
    End Sub

    
End Class




US Dollar To Philippine Peso Converter in Visual Basic NET

Here is a simple program that I wrote using Microsoft Visual Basic NET to ask the user to give an amount in US Dollars and then it will convert into Philippine Peso equivalent. Let us assume that one US Dollar is equivalent to Php 45.50 in Philippine Pesos. The code is very easy to understand I started learning Visual Basic NET in my spare time.

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

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 Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim compute_peso As Double
        compute_peso = (Val(TextBox1.Text) * 45.5)
        Label4.Text = "The Philippine Peso Rate is Php " & Format(compute_peso, "0.00")
    End Sub

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

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim result As DialogResult = MessageBox.Show("Do you want to quit?", _
                               "Quit Program", _
                               MessageBoxButtons.YesNo)

        If (result = DialogResult.Yes) Then
            End
        Else
            TextBox1.Text = ""
            Label4.Text = ""
            TextBox1.Focus()
        End If
    End Sub

    
End Class