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

 
 


boold
Write a java application program........?
1 Answer(s)      a year and a month 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

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 Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.