Thursday, July 23, 2015

Passed and Failed Program in Java

This is a program in Java that I wrote using one dimensional array as my data structure that will check the number of passing and failing grade of students. The code is very simple yet very useful for students and other people who are getting started learning Java programming.

I hope you will find my work useful and beneficial. If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.comand 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
    

Positive and Negative Numbers in Java

This simple program will give you a first hand idea how to use one dimensional array in Java. What the program does is to ask the user to give a series of numbers and then the program will display the positive and negative numbers that is being given by our user.

I hope you will find my work useful and beneficial. If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.comand 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

/*
positive_negative_numbers_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 numbers and then
the program will enumerate the positive and negative numbers based 
on the given numbers by the user.
*/
              

import java.util.Scanner;

class positive_negative_numbers_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;
      System.out.print("POSITIVE AND NEGATIVE NUMBERS PROGRAMS");
      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 POSITIVE NUMBERS");
         System.out.println();
      for (int a=0; a<10; a++)
      {
         if(values[a]>= 0) {
                System.out.print(" " + values[a]+ " ");
                }
       
      }        
      System.out.println(); 
      System.out.print("LIST OF NEGATIVE NUMBERS ");
      System.out.println(); 
      for (int a=0; a<10; a++)
      {
         if(values[a] < 0) {
               System.out.print(" " + values[a]+ " ");
                }
      }     
     System.out.println("\n\n"); 
     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
    

Odd and Even Numbers in Java

I this article I would like to share with you a program that I wrote in Java SE I called this program Odd and Even Numbers Program that will ask the user to enter a series of numbers and then our program will list down the even and odd numbers using one dimensional array as our data structure.

I hope you will find my work useful and beneficial. If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.comand 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

/*
odd_even_numbers_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. 3:
  
Write a program that will ask the user to give ten numbers and then
the program will enumerate the odd and even numbers based on the 
given numbers by the user.
*/
              

import java.util.Scanner;

class odd_even_numbers_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;
      System.out.print("ODD AND EVEN NUMBERS PROGRAMS");
      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 EVEN NUMBERS");
         System.out.println();
      for (int a=0; a<10; a++)
      {
         if(values[a]%2 == 0) {
                System.out.print(" " + values[a]+ " ");
                }
      }        
      System.out.println(); 
      System.out.print("LIST OF ODD NUMBERS ");
      System.out.println(); 
      for (int a=0; a<10; a++)
      {
         if(values[a]%2 != 0) {
               System.out.print(" " + values[a]+ " ");
                }
      }     
     System.out.println("\n\n"); 
     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
    


Grade Solver in Java

A program that I wrote in Java that will compute the average grade of the student in different subjects. I am using one dimensional array in this sample program the code is very simple and easy to understand.

I hope you will find my work useful and beneficial. If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.comand 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

/*
average_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. 2:
  
Write a program that will ask the user to give eight grades for
eight subjects and then our program will find average grade of 
the student from the eight subjects.
*/
              

import java.util.Scanner;

class grade_array {
    
public static void main(String[] args) {
      
     Scanner input = new Scanner(System.in);
     char ch;
     String[] subjects = new String[]
     {"Computer", "Math", "English","Physical Education",
      "History","Science","Music and Arts","Filipino"};
     
  do { 
      int [] values; 
      values  = new int[8];  
      int x=0,average_grade=0,total_sum=0;
      System.out.print("Average Grade Solver");
      System.out.println();
      for (int a=0; a<8; a++)
      {
         x=1;
         x+=a;
         System.out.print("Enter your subject grade on " + subjects[a] + " : ");
         values[a] = input.nextInt();
         total_sum+=values[a];
         average_grade = total_sum/8;
      }
     System.out.println(); 
     System.out.println();
     System.out.print("Your average grade is 8 subject is " + average_grade + ".");
     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

Sum and Average of Five Numbers in Java

In this article I would like to share with you a very simple programs intended for beginners I called this program Sum and Average of Five Numbers in Java that uses one dimensional array. What does this program will do is ask the user to enter five numbers and then it will find the sum and average of the given numbers by our user.

I hope you will find my work useful and beneficial. If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.comand 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

/*
average_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. 1:
  
Write a program that will ask the user to give five numbers 
and then our program will find the total sum and average of
five numbers using an array.
*/


import java.util.Scanner;

class average_array {
    
public static void main(String[] args) {
      
     Scanner input = new Scanner(System.in);
     char ch;
   
  do { 
      int [] values; 
      values  = new int[5];  
      int x=0, total_sum=0, average=0;
      System.out.print("Sum and Average of Five Numbers");
      System.out.println();
      for (int a=0; a<5; a++)
      {
         x=1;
         x+=a;
         System.out.print("Enter value in item no." + x + " : ");
          
         values[a] = input.nextInt();
         total_sum += values[a];
         average = total_sum/5;
      }
     System.out.println(); 
     System.out.print("The total sum is " + total_sum + ".");
     System.out.println();
     System.out.print("The average of five numbers is " + average + ".");
     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");
  }
}




Wednesday, July 22, 2015

Civil Status Checker in Java

A very simple program that I wrote in Java using NetBeans IDE to ask the user it's civil status whether the user is single, married, divorce or annulled it will display the result on the screen. The program is very simple I just wrote this for beginners that are new in Java programming.

I hope you will find my work useful and beneficial. If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.comand 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

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

Problem No. 3:
  
Write a program check the civil status of a person either the person
is SINGLE, MARRIED, ANNULLED, SEPARATED or WIDOW.
*/


import java.util.Scanner;

class civil_status {
    
public static void main(String[] args) {
      
     Scanner input = new Scanner(System.in);
     char ch;
    
  do { 
      char selected_status=0; 
      System.out.print("Civil Status Checker ");
      System.out.println();
      String user_name = input.nextLine();
      System.out.print("Enter your Name : ");
      String user_name2 = input.nextLine();
      System.out.println("Select Your Civil Status ");
      System.out.print("1 - SINGLE, 2 - MARRIED, 3 - ANNULLED"
              + ", 4 - SEPARATED, 5 - WIDOW  : ");
      selected_status = input.next().charAt(0);      
      
      if (selected_status == '1') {
          System.out.println();
          System.out.print("Hi " + user_name2 + " you are still Single.");
          }
      else if (selected_status == '2') {
          System.out.println();
          System.out.println("Hi " + user_name2 + " you are already Married.");
         }
      else if (selected_status == '3') {
          System.out.println();
          System.out.print("Hi " + user_name2 + " you are already Annulled.");
         }
      else if (selected_status == '4') {
          System.out.println();
          System.out.print("Hi " + user_name2 + " you are already Separated.");
         }
      else if (selected_status == '5') {
          System.out.println();
          System.out.print("Hi " + user_name2 + " you are already Widow.");
         }
      else  {
          System.out.println("Sorry Invalid Option Try Again.");
      }  
     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");
  }
}



Year Level in Java

In this article I would like to share with you a sample program that I wrote in Java using NetBeans as my integrated development environment I called this program year level checker or determiner that show the user how to use if else statement in Java. This program is for beginners that are very new in Java programming.

I hope you will find my work useful and beneficial. If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.comand 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

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

Problem No. 4:

Design a program to display the year level of students based on their
year entry number. Here are the given criteria: 
(using if-else statement).

*/


import java.util.Scanner;

class year_level2 {
    
public static void main(String[] args) {
      
     Scanner input = new Scanner(System.in);
     char ch;
    
  do { 
      
      System.out.print("\t\t MARMELO V. ABANTE INSTITUTE OF SCIENCE AND TECHNOLOGY ");
      System.out.println();
      System.out.print("\t\t 12 Mangga St., Brgy.Papaya, Tingloy, Batangas, Batangas City");
      System.out.println("\n");
      System.out.print("Enter your year level now : ");
      int year_level = input.nextInt();
          
      if (year_level == 1) {
          System.out.println();
          System.out.print("You are in a Freshman Status.");
          }
      if (year_level == 2) {
          System.out.println();
          System.out.println("You are in a Sophomore Status.");
         }
     if (year_level == 3) {
          System.out.println();
          System.out.print("You are in a Junior Status.");
         }
      if (year_level == '4') {
          System.out.println();
          System.out.print("You are in Senior Status.");
         }
      else if (year_level > 4 || year_level < 1) {
          System.out.println("Sorry You are out of school youth.");
      }  
     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");
  }
}




Sunday, July 19, 2015

Numbers To Roman Numeral in Java

A simple program in Java that will ask the user to give a number in integer format and then the program will convert the given decimal number into roman numeral equivalent.

I hope you will find my work useful and beneficial. If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.comand 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

// decimal_romans.java
// Programmer : Mr. Jake R. Pomperada, MAED-IT
// Date       : July 19, 2015
// Tools      : Netbeans 8.0.2
// Email      : jakerpomperada@yahoo.com and jakerpomperada@gmail.com

import java.util.Scanner;

class decimal_romans
{
public static void main(String args[]) 
{
     Scanner input = new Scanner(System.in);
        
      char ch;
     
 do {

String thousands[]={"","M","MM","MMM","MMMM"};
String hundreds[]={"","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"};
String tens[]={"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"};
String units[]={"","I","II","III","IV","V","VI","VII","VIII","IX"};

System.out.println();
System.out.print("\t  NUMBER TO ROMAN NUMERALS ");
System.out.println("\n");
System.out.print("Enter a Number : ");
int number = input.nextInt();

if(number>0 && number<5000)
{

int th=number/1000;
int h=(number/100)%10;
int t=(number/10)%10;
int u=number%10;

System.out.println("Roman Equivalent= "+thousands[th]+hundreds[h]+tens[t]+units[u]);
}
 else
System.out.println("nYou entered a number out of Range."
        + "Please enter a number in the range [1-4999] only");
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");
 }

}


Second Highest Number in Java

In this simple program it will ask the user to enter five numbers and then our program will check and determine which of the five number has the second highest value.

I hope you will find my work useful and beneficial. If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.comand 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

// finding_second.java
// Programmer : Mr. Jake R. Pomperada, MAED-IT
// Date       : July 19, 2015
// Tools      : Netbeans 8.0.2
// Email      : jakerpomperada@yahoo.com and jakerpomperada@gmail.com

// Write a program in Java using one dimensional array that will ask the user
// to give five numbers and then the program will determine which of the five
// number is the second to the highest number.

import java.util.Scanner;
 
public class finding_second {
    
    public static void main(String[] args) {
      Scanner input = new Scanner(System.in);
      
     char ch;   
 do {
    int values[]=new int[5];
    int highest = Integer.MIN_VALUE;
    int highest2nd = Integer.MIN_VALUE;
    
     System.out.println();
      System.out.print("\t FINDING SECOND HIGHEST NUMBER");
      System.out.println("\n");
    for(int i=0;i<5;i++){
        int x=(i+1);
         System.out.print("Enter Value Number " + x + ": ");
          values[i]=input.nextInt();

    }
    for(int i=0;i<5;i++){
        if (values[i]>=highest) { 
            highest2nd = highest;
            highest = values[i];
        } else if (values[i]>= highest2nd)
            highest2nd =values[i];
    }
    System.out.println();
    System.out.println("The second highest number is " + highest2nd +"."); 
     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");
    }
}


Pascal Triangle in Java

A simple program that I wrote using Java that will display Pascal Triangle using the value that is being given by the user.

I hope you will find my work useful and beneficial. If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.comand 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

// pascal_triangle.java
// Programmer : Mr. Jake R. Pomperada, MAED-IT
// Date       : July 19, 2015
// Tools      : Netbeans 8.0.2
// Email      : jakerpomperada@yahoo.com and jakerpomperada@gmail.com

import java.util.Scanner;

public class pascal_triangle{

public static void main(String[] args) {
 Scanner input = new Scanner(System.in);
                char ch;
         do {   
      System.out.println();
               System.out.print("\t Pascal Triangle Generator ");
               System.out.println("\n");
      
               System.out.print("Enter a number please  : "); 
              int value = input.nextInt();
     System.out.println();
              for(int i =0;i<value;i++) {

              int number = 1;

              System.out.format("%"+(value-i)*2+"s","");

            for(int j=0;j<=i;j++) {
                 System.out.format("%4d",number);
                 number = number * (i - j) / (j + 1);
            }
           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");
}
}