Saturday, June 25, 2016

Decimal To Binary Converter in Java

This simple program will ask  the user to give a  number and then our program will convert the given number by the user into binary equivalent. The program is very easy to understand and use.


 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


Decimal_binary.java


package hello;

import java.util.Scanner;

public class Decimal_binary {

public static void main(String args[]) {

Scanner input = new Scanner(System.in);
int values = 0;

System.out.println("Decimal To Binary Converter in Java");
System.out.println();
System.out.print("Enter a Number : ");
values = input.nextInt();

String binary_value = Integer.toBinaryString(values);

System.out.println("The Binary Value is : " + binary_value + ".");
System.out.println();
System.out.println("\t End of Program");
}
}

Decimal To Octal Converter in Java

This simple program will ask  the user to give a  number and then our program will convert the given number by the user into octal equivalent. The program is very easy to understand and use.


 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

decimal_octal.java

package hello;

import java.util.Scanner;

public class decimal_octal {

public static void main(String args[]) {

Scanner input = new Scanner(System.in);
int values = 0;

System.out.println("Decimal To Octal Converter in Java");
System.out.println();
System.out.print("Enter a Number : ");
values = input.nextInt();

String octal_value = Integer.toOctalString(values);

System.out.println("The Octal Value is : " + octal_value + ".");
System.out.println();
System.out.println("\t End of Program");
}
}

Sum and Average of Numbers Using Array in Java

A simple program that I wrote in Java to find the sum and average of numbers using one dimensional array in Java. What the program does it will ask the user to give a series of integer number and then the program will compute the sum and average of the five numbers given by the user of our program.

 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

sum_array.java

package hello;

import java.util.Scanner;

public class sum_array {

 
 public static void main(String args[]){
 
 Scanner input = new Scanner(System.in);
    
       int num[]=new int[5];
       int average=0,i=0,sum=0;
     
       System.out.println("Sum and Average of Numbers Using Array in Java");
       System.out.println();
       for (i=0;i<num.length;i++) {
       
       
          System.out.print("Enter a Number : ");
           num[i]=input.nextInt();
           sum=sum+num[i];
       }
       
       average=(sum/5);
       
       System.out.println();
       System.out.println("The total sum is  "+ sum + ".");
       System.out.println();
       System.out.println("The average is "+average+".");
       System.out.println();
       System.out.println("\t End of Program");
 
 }
 
 
}





Simple Inheritance in Java

A simple program that I wrote in Java to show how the concepts of inheritances works. This program will greet the user three times when we assign a name of the user in a string. The code is very easy to understand and learn ideal for those that are new in Java programming.

 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

Simple_Inheritance.java


package hello;


class hello_world{ 

 public void greet2(String user){
        System.out.println("Hello " + user + " How are you?");
        System.out.println();
  }
 public void greet3(String user){
        System.out.println("Kamusta ka " + user + " Welcome to Philippines.");
        System.out.println();
        System.out.println("\t End of Program");
     }
 
}


public class Simple_Inheritance extends hello_world {
 public void greet1(String person1){
    System.out.println("\t Simple Inheritance in Java");
    System.out.println();
        System.out.println("Welcome " + person1 + " to our home.");
        System.out.println();
  }
 public static void main(String args[]){
 String name="Jake R. Pomperada";
 
 Simple_Inheritance person = new Simple_Inheritance();
 person.greet1(name);
 person.greet2(name);
 person.greet3(name);
 
  }
}


 

Sunday, June 19, 2016

Multiply Two Numbers in C++ Using Classes

This simple program in C++ will show you how to multiply them using Classes. 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.



Program Listing

#include <iostream>
#include <string>

using namespace std;

class multiply {
    int val1,val2;
    char reply;
    public:
    int get_data();
    void display_result(void);
};


int multiply :: get_data()
{
    while (1) {
    system("cls");
    cout << "enter two number :";
    cin >> val1>> val2;
    cout << "\n\n The Product is " << (val1*val2);
    cout << "\n\n";
    cout << "More Y Or N : ";
    cin >> reply;

    if (tolower(reply) == 'n') {
        cout << "Thanks";
        break;
    }
    }
}

void multiply :: display_result(void)
{
    int val=0;
    val = get_data();
}

main() {
    multiply numbers;

    numbers.display_result();
}



If Else Statement in C#

This sample program written in C# will show you how to use if else statement this sample program is being provided by my good friend and fellow programmer Mr. Dave Marcellana.

 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

if-else.cs

using System;

public class if-else
{
    public static void Main()
    {
        int n;
        for(n=0; n<21; n++)
        {
            if(n == 0)
            {
                Console.WriteLine("First one: " + n);
            }
            else if(n < 5)
            {
                Console.WriteLine("Less than five: " + n);
            }
            else if(n == 10 || n == 11)
            {
                Console.WriteLine("Ten or Eleven: " + n);
            }
            else if(n >= 13 && n <= 18)
            {
                Console.WriteLine("YEHEY!!");
            }
            else
            {
                Console.WriteLine("Not less than five: " + n);
            }
        }
    }
}

Hello World in C#

Here is a simple hello world program in C# provided by my friend Dave Marcellana.


 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

HelloWorld.cs


using System;


public static class HelloWorld
{
    public static void Main()
    {
        Console.WriteLine("Hello World!");
    } 
}

    

Sum of Odd and Even Numbers in C++

This simple C++ program will compute the sum of odd and even numbers from the given number by the user. 


 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

#include <iostream>

using namespace std;

int main()
{
    int a=0, number=0, odd_sum = 0, even_sum = 0;

    cout << "Sum of ODD and Even Numbers in  C++";
    cout << "\n\n";
    cout << "Give a number  : ";
    cin >> number;

    for (a = 1; a <= number; a++)
    {
        if (a % 2 == 0)
            even_sum = (even_sum + a);
        else
            odd_sum = (odd_sum + a);
    }
    cout << "==== The Result =====";
    cout << "\n\n";
    cout << "Sum of all odd numbers is " << odd_sum << ".\n";
    cout << "Sum of all even numbers is " << even_sum << ".";
    cout << "\n\n";
    cout << "\t\t End of Program";
    cout << "\n\n";

}


Loan Program in C++ Using Text File

A simple loan program that I wrote using C++ as my programming language to compute the interest rate of a loan of the customer and then it will store in a text file which act as our database.

 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>
#include <iomanip>
#include <fstream>


using namespace std;

main() {

    string name;

    int principal=0;
    int number_months=0;
    float rate=0.00,solve_rate=0.00;

    ofstream file("report.txt");

    cout << "\t  Kwarta Agad Lending Investor";
    cout << "\n\n";
    cout << "Enter Customer Name    :=> ";
    getline(cin,name);
    cout << "\nEnter Amount  Loan   :=> ";
    cin >> principal;
    cout << "\nNumber of Months    :=> ";
    cin >> number_months;
    cout << "\nEnter Rate Per Month :=> ";
    cin >> rate;
    solve_rate = (principal * number_months * rate ) ;
    cout << "\n\n";
    cout << fixed << setprecision(2);
    cout << "The Simple Interest Rate is Php "
         << solve_rate << ".";

    file << "\n\t ======= Kwarta Agad Lending Investor =========";
    file << "\n\n";
    file << "\n\t\t CUSTOMER REPORT";
    file << "\n\n";
    file << "\n Customer Name     : " << name;
    file << "\n Amount   Loan     : " << principal;
    file << "\n Number of Months  : " << number_months;
    file << "\n Rate Per Month    : " << rate;
    file << "\n\n";
    file << fixed << setprecision(2);
    file << "\n Interest Rate is Php " << solve_rate;
    file.close();
    cout << "\n\n";
    system("pause");
}


Greeter Program in C++ Using Text File

This sample program is an class programming activity that I wrote five years ago in my programming class in C++. What does the program will do is to ask the users name and other information and then those information will be process and stored in a text file. This code will teach how to use text file using C++. I hope you will find my work useful.

 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>
#include <fstream>


using namespace std;

main() {

    string name, address;
    int age=0;

    ofstream file("greet.txt");

    cout <<  "\n\t Greeter Version 1.0 ";
    cout << "\n\n";
    cout << "Enter your name         :=> ";
    getline(cin,name);
    cout << "\nEnter your address    :=> ";
    getline(cin,address);
    cout << "\nEnter your age        :=> ";
    cin >> age;

    cout << "\n\n";
    cout << "\nHello " << name << " " << " Welcome to USLS - Bacolod ";
    cout << "\n You home address is " << address;
    cout << "\n You are already " << age
         << " years old.";
    file << "\n\n";
    file << "\n ======== Greeter Version 1.0 =========";
    file << "\n\n";
    file << "\n Hello " << name << " " << " Welcome to USLS - Bacolod ";
    file << "\n You home address is " << address;
    file << "\n You are already " << age
         << " years old.";
    file.close();
    cout << "\n\n";
    system("pause");
}

Volume of a Cube in C

In this article I would like to share with you a sample program that I wrote using C as my programming language. I called this program volume of a cube in c that will ask the user to give the base, length, height of the cube and then our program will compute for it it's volume. The code is very simple I intended my work for beginners in C programming.

 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

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

int main()
{
    int length=0, base =0, height=0, volume=0;
    printf("Volume of a Cube in C");
    printf("\n\n");
    printf("Give the value in length   : ");
    scanf("%d",&length);
    printf("Give the value in base     : ");
    scanf("%d",&base);
    printf("Give the value in height   : ");
    scanf("%d",&height);

    volume = (length * base * height);

    printf("==== The Result =====");
    printf("\n\n");
    printf("The volume of the cube is %d.",volume);
    printf("\n\n");
    printf("\t\t End of Program");


}



Sunday, June 12, 2016

Square Root and Absolute Value in C++

A square root and absolute value in C++ program that I wrote a long time ago in my programming class in college. The code is very easy to understand and learn for beginners that are new in C++ programming.

 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>
#include <math.h>

using namespace std;

class square_root {
    public:
    int value;

};


main() {
     square_root number;

      cout << "\t\t Square Root and Absolute Value Solver 1.0 ";
      cout << "\n\n";
      cout << "Enter A Number : ";
      cin >> number.value;
      cout << "\n\n";
      cout << "The Square Root Value of "
           << number.value << " is " << sqrt(number.value) << ".";
      cout << "\n";
      cout << "The Absolute Value of "
           << -number.value << " is " << abs(number.value) << ".";
      cout << "\n\n";
      system("pause");
}