Pass_Fail 4-2

posted Feb 5, 2014, 11:03 AM by Dlovan ismail   [ updated Feb 5, 2014, 11:04 AM by Karwan Jacksi ]
//Write a java program that reads 7 student grades then print the number of pass and fail students ?

package pass_fail;
import java.util.Scanner;//Needed for class Scanner

public class Pass_Fail 
{
    public static void main(String[] args)
    {
            System.out.println("Enter input degree (between 0-100) of 7 students :");

            //Create a class Scanner for inputting data.
            Scanner input=new Scanner(System.in);


            int pass=0; //number of pass students.
            int n;             //For storing the entered value.
            int i=1;

            while(i<=7)
            {
                n=input.nextInt();

                if(n>=50)
                    pass++;

                i++;   
            }

            System.out.println( "Number of Passed students :"+pass);
            System.out.println( "Number of failed students :"+(7-pass));
    }   
}

ċ
Pass_Fail.java
(1k)
Karwan Jacksi,
Feb 5, 2014, 11:03 AM
Comments