Monday, August 31, 2015

Low and High Number Checker Using Two Dimensional Array in C++

In this program it will ask the use to enter two numbers and then the program will compare and determine which to the two number is the higher and the lowest in terms of value using two dimensional array in C++.

If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.


Sample Program Output

Program Listing


#include <iostream>

using namespace std;

void display(void)
{
 int high=0,low=0;

int val[2][1];

cout << "\t Low and High Number Checker 1.0";
cout << "\n\n";
cout << "Enter two numbers :=> ";
cin >> val[0][0] >> val[1][0];

 if (val[0][0] > val[1][0]){
     high = val[0][0];
     low = val[1][0];
 }
    else if (val[1][0] > val[0][0] ){
     high = val[1][0];
     low = val[0][0];
 }
 else if (val[1][0] == val[0][0])
 {
     cout << "\n\n";
     cout << "They have the same value. Try Again";
 }
 cout << "\n=======================";
 cout << "\n   Display Result      ";
 cout << "\n=======================";
 cout << "\n\n";
 cout << "\n Highest Number ==> " << high << ".";
 cout << "\n Lowest  Number ==> " << low <<  ".";
 cout << "\n\n";
 system("pause");
}

main()
{
 display();
}


Square and Cube Root in C++

This article show you how to use for loop iteration statement in C++ and the use of functions I called this program Square and Cube Root in C++.  That will ask the user to enter a number and then it will generate the square and cube root value of the given number.

If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.


Sample Program Output

Program Listing

#include <iostream>
#include <iomanip>
#include <fstream>

using namespace std;

 ofstream file("output.txt");

int square_cube(int x_value)
{
    cout <<"\n\n";

    cout <<setw(3)<< "\n Number" << setw(12)
            << "SQUARE" << setw(14)
            << "CUBE ROOT";
            cout << "\n";
    for (int y=1; y<= x_value; y+=1)
    {
        cout <<"\n"<<setw(5) << y << setw(12)
             << y * y << setw(12)
             << y * y * y;
    }

    file << "\t SQUARE AND CUBE ROOT VERSION 1.0";
    file <<"\n\n";

    file <<setw(3)<< "\n Number" << setw(12)
            << "SQUARE" << setw(14)
            << "CUBE ROOT";
            file << "\n";
    for (int y=1; y<= x_value; y+=1)
    {
        file <<"\n"<<setw(5) << y << setw(12)
             << y * y << setw(12)
             << y * y * y;
    }
    file.close();
    cout << "\n\n";
    system("pause");
}



main() {
    ofstream file("output.txt");

    int value=0;
    cout << "\n\n";
    cout << "\t SQUARE AND CUBE ROOT VERSION 1.0";
    cout << "\n\n";
    cout << "Enter a Number :=> ";
    cin >> value;

    square_cube(value);
}



Addition of Two Numbers Using Pointers and Classes in C++

A simple program that I wrote in C++ that will ask the user to enter a number and then our program will find the sum of two numbers using pointers and classes as our data structure in C++ programming.

If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.


Sample Program Output

Program Listing

#include <iostream>

using namespace std;

class add {
public:
    int a,b;

 int convert(int *a, int *b )
     {
     return(*a+*b);

     }
};

 main() {
    add values;
    char reply;

  while (1) {
    system("cls");
    cout << "\n\n\t Addition Program Using Class and Pointers ";
    cout << "\n\n \t Created By: Mr. Jake R. Pomperada, MAED-IT";
    cout << "\n";
    cout << "\n\n Enter the first value  : ";
    cin >> values.a;
    cout << "\n Enter the second value : ";
    cin >> values.b;
    cout << "\n\n";
    cout << " The total sum is ";
    cout << values.convert(&values.a,&values.b);
    cout << ".";
    cout <<"\n\n";
    cout << " More Y/N :=> ";
    cin >> reply;

    if (reply == 'N' || reply == 'n') {
        cout << "\n\n";
        cout << "\t Thank You For Using This Program :-D";
        break;
    }
    }
    cout << "\n\n\n\n";
    system("pause");
}


Addition of Five Numbers Using Class in C++

In this article I would like to share with you how to declare and use a class in C++. This program I called addition of three numbers using a class in C++. It will ask the user to enter five numbers and then it will compute and display the total sum of the three numbers.

If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.


Sample Program Output

Program Listing

#include <iostream>

 using namespace std;

 class add {
     public:
     int a,b,c,d,e;

     int solve(int a,int b,int c, int d, int e)
      {
          return(a+b+c+d+e);
      }
 };


 main() {

      add values;

     cout << "\n\t Addition of Numbers ";
     cout << "\n\n";
     cout << "Enter five numbers : ";
     cin >> values.a >> values.b
         >> values.c >> values.d
         >> values.e;
     cout << "\n\n";
     cout << "The total sum "
          << values.solve(values.a,values.b,
                   values.c,values.d,
                   values.e) << ".";
     cout << "\n\n";
     system("pause");
 }






Student Average Grade Solver Using Classes in C++

In this article I would like to share with you a program that I wrote before for my programming class in C++ I called this program student average grade solver using classes in C++.  What does the program will do is to ask the name of the students, subject and its responding grade and then the program will compute the average grade of the student.

If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.



Sample Program Output

Program Listing

#include <iostream>


using namespace std;

class students {
    public:
    int grade[3];
    string name;
    char subjects[3][500];
};


main() {

    students person;
    int x=0,sum=0,solve_grade=0;;

    cout << "\t\t Average Grade Solver 1.0";
    cout << "\n\n";

    cout << "Enter Student Name :";

    getline(cin,person.name);
      for (x=0; x<3; x++) {
         cin.ignore();
          cout << "\nEnter Subject Name :";

           gets(person.subjects[x]);
          cout << "Enter Subject Grades  :";
          cin >> person.grade[x];
            sum+= person.grade[x];
            solve_grade=(sum/3);
      }
      cout << "\n=============================";
      cout << "\n     Generated Report        ";
      cout << "\n=============================";
      cout << "\n";
      cout << "\n Student Name : " << person.name;
        cout << "\n";
        for ( x=0; x<3; x++) {

            cout <<"\n Subject : " << person.subjects[x];
            cout <<"\n Grade   : " << person.grade[x];
       }

        cout << "\n\n";
        cout << "Average Grade in 3 Subjects is  "
             << solve_grade <<".";
        cout << "\n\n";
        system("pause");
}



Basic Math Operations Using Classes in C++

In this article I would like to share with you a basic math operations using classes in C++. In basic mathematics there are four operations addition, subtraction, multiplication and division. In our example I am using classes, attributes and method to solve the problem. The code is very easy to understand and use a good way to learn object oriented programming using C++.

If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.



Sample Program Output

Program Listing

#include <iostream>

 using namespace std;

 class math {

     private:
       int x,y;
       int sum,divide;

     public:
       int process_data();
       int display();
 };


 int math :: process_data()
 {
    cout << "\n \t Basic Math Operations";
    cout << "\n\n";
    cout<<"Enter x value: ";
cin>>x;
cout<<"Enter y value: ";
cin>>y;

    sum    = x + y;
    divide = x - y;

    cout<<"\n sum        = "<<sum
        <<"\n difference = "<<divide
   <<"\n quotient   = "<<x/y
   <<"\n product    = "<<x*y
   <<"\n remainder  = "<<x%y
        <<"\n";
    cout << "\n\n";
    system("pause");
 }

 int math :: display()
  {
      int basic;
      basic = process_data();
  }

  main() {
      math value;
      value.display();
  }



Area of the Triangle Using Classes in C++

In this article I would like to share with you again a program that I wrote that will solve the are of the triangle using classes in C++. The code is very easy to understand that teaches the fundamentals of object oriented programming in C++ programming language.

If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.


Sample Program Output

Program Listing


#include <iostream>

  using namespace std;

  class triangle {

      public:
            double b,h;
  };

 main()
{
    triangle values;

    cout<<"\n [ Area of a triangle ]"<<endl;
    cout << "\n\n";
    cout<<"Enter Base    : ";
    cin>>values.b;
    cout<<"Enter Height  : ";
    cin>>values.h;
    cout << "\n\n";
    cout<<"Area = "
        <<(values.b*values.h)/2
        <<" square units ";
    cout << "\n\n";
    system("pause");
}

Prime Number Checker Using Classes in C++

A simple program that I wrote a long time ago while learning C++ object oriented programming I called this program prime number checker using classes in C++ that will ask the user to enter a number and then our program will check if the number given is prime number or not a prime number.

If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.



Sample Program Outputn

Program Listing

#include <iostream>

using namespace std;

class prime {

  public:
   int n;

   int smalldiv (int n) {
  int count;
  count = 2;

  while (count < n && n % count != 0) {
    count = count + 1;
  }
  return(count);
}
};

 main () {

  prime value;

  cout << "\t Prime Number Checker 1.0";
  cout << "\n\n";

    while (1) {
        cout << "\n";
        cout << "Enter a number: ";
        cin >> value.n;
        if (value.n == 0) {
            cout << "\n\n";
            cout << "Thank you for using this Program.";
            break;
        }
        cout << "\n";
            if (value.n == value.smalldiv(value.n)) {
                cout  << value.n << " is a prime number" << endl;
            }
    else {
        cout << value.n << " is not a prime number" << endl;
        }

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



Rectangle Area Solver Using Classes in C++

In this article I would like to share with you a sample program that will compute the area and base of the rectangle using Classes in C++. The code will give you a first hand experience how to create an object, methods and attributes in object oriented programming in C++.

If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.



Sample Program Output

Program Listing

#include <iostream>

 using namespace std;

 class rectangle {
   private:
   float base,height;

   public:

   float area(float b,float h)
    {
       return(b*h);
    }

    float process_data();
    float display_data();
 };

 float rectangle :: process_data()
   {
    cout << "\n";
    cout<<"\t\t AREA OF A RECTANGLE\n";
    cout << "\n";
    cout<<"\nEnter Base   : ";
    cin>>base;

    cout<<"\nEnter Height : ";
    cin>>height;

    cout << "\n\n";
    cout<<"\nArea = "
        <<area(base,height)
        <<" Square Units\n";
    cout << "\n\n";
    system("pause");
   }

   float rectangle :: display_data()
   {
       float math;

       math = process_data();
   }

main() {
    rectangle number;
    number.display_data();
}



Sunday, August 30, 2015

Passed and Failed Grade Counter in Java

In this article I would like to share a sample program that will ask the user to enter a series of grades and then our program will count and display the passing and failing grades among students in a class using one dimensional array in Java.

If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.

Sample Program Output


Program Listing

/*
pass_failed_grades_array.java
Programmer By: Mr. Jake R. Pomperada, MAED-IT
Date : July 23, 2015
Tools: NetBeans 8.0.2, Java SE 8.0

Problem No. 4:
  
Write a program that will ask the user to give ten grades and then
the program will enumerate the passing and failing grade based on
the grades given by the user. Take note the passed grade is 75%.
*/
              

import java.util.Scanner;

class pass_failed_grades_array{
    
public static void main(String[] args) {
      
     Scanner input = new Scanner(System.in);
     char ch;
        
  do { 
      int [] values; 
      values  = new int[10];  
      int x=0;
      int no_passed=0, no_failed=0;
      System.out.print("PASS AND FAILED GRADE PROGRAM");
      System.out.println();
      for (int a=0; a<10; a++)
      {
         x=1;
         x+=a;
         System.out.print("Enter value in item no. " + x + " : ");
         values[a] = input.nextInt();
        }       
         System.out.println(); 
         System.out.print("LIST OF PASSING GRADES");
         System.out.println();
      for (int a=0; a<10; a++)
      {
         if(values[a]>= 75) {
                System.out.print(" " + values[a]+ " ");
                no_passed++;  
           }
       
      }        
      System.out.println(); 
      System.out.print("LIST OF FAILING NUMBERS ");
      System.out.println(); 
      for (int a=0; a<10; a++)
      {
         if(values[a] < 75) {
               System.out.print(" " + values[a]+ " ");
               no_failed++;  
              }
      }     
     System.out.println("\n\n");  
     System.out.println("Number of Passing Grade is " + no_passed + ".");
     System.out.println("Number of Failing Grade is " + no_failed + ".");
     System.out.println();
     System.out.print("\nDo you want to continue (Type y or n) : ");
     ch = input.next().charAt(0);                        
     } while (ch == 'Y'|| ch == 'y');  
     System.out.println();
     System.out.print("\t THANK YOU FOR USING THIS PROGRAM");
     System.out.println("\n\n");
  }
} // End of Code