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
    

No comments:

Post a Comment