Sunday, January 29, 2017

Maximum of Three Numbers in Visual Basic NET

Here is a sample program that I wrote using Microsoft Visual Basic NET that will ask the user to give three numbers and then it will check which of the three numbers is the maximum in terms of numerical value.  The code is very short and easy to understand. 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

    Function Maximum(ByVal valueOne As Double, _
       ByVal valueTwo As Double, ByVal valueThree As Double) _
       As Double
        Return Math.Max(Math.Max(valueOne, valueTwo), valueThree)
    End Function
  
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        End
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim val1, val2, val3 As Integer

        val1 = Val(TextBox1.Text)
        val2 = Val(TextBox2.Text)
        val3 = Val(TextBox3.Text)

        Label4.Text = "The biggest number is " & Maximum(val1, val2, val3) & "."
    End Sub
End Class






Square and Cube Value Solver in Visual Basic NET

Hi there in this article I would like to share with you a sample program that I wrote in Visual Basic NET to ask the user to give a number and then our program will compute the square and cube value of the given number. 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
    Function Square(ByVal y As Integer) As Integer
        Return y ^ 2
    End Function

    Function Cube(ByVal y As Integer) As Integer
        Return y ^ 3
    End Function


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Label2.Text = "The square value of " & TextBox1.Text & " is " & Square(Val(TextBox1.Text)) & "."
        Label3.Text = "The cube vallue of " & TextBox1.Text & " is " & Cube(Val(TextBox1.Text)) & "."
    End Sub

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

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




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();
   }

}