Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Interview-Questions Write a java application program........?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


boold
Write a java application program........?
1 Answer(s)      2 years and 5 months ago
Posted in : Java Interview Questions


Welcome every One : I have Q in Java?

Q : Write a java application program that reads 20 integer numbers input by the user and prints how many numbers > 100 and how many numbers less than 100?

thanks


Advertisement
View Answers

April 24, 2012 at 11:37 AM


import java.util.*;

class NumberExample 
{
    public static void main(String[] args) 
    {
        int count1=0;
        int count2=0;
        Scanner input=new Scanner(System.in);
        System.out.println("Enter 20 numbers:");
        int i=1;
        while(i<=20){
            int num=input.nextInt();
            if(num>100){
             count1++;
            }
            else if(num<100){
            count2++;
            }
            i++;
        }
            System.out.println(count1+" numbers are greater than 100");
            System.out.println(count2+" numbers are smaller than 100");
    }
}


Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com