Home Answers Viewqa Java-Beginners java program based on array

 
 


nainshi jain
java program based on array
1 Answer(s)      2 years and 2 months ago
Posted in : Java Beginners

write a program to create an array of 10 integers in main.accept values from the user in that array .now again ask the use another nomber and pass the array and the no. entered to function called count() belonging to a class counter.within count findout how many numbers are equal to the no. passed how many are greater and how many are less than the no. passed .finally return the result block to main and print it there.

View Answers

March 14, 2011 at 11:15 AM


import java.util.*;
class ArrayExample8
{
    public static void main(String[] args) 
    {
        int less=0,more=0;
        Scanner input=new Scanner(System.in);
        System.out.println("Enter array elements: ");
        int array[]=new int[10];
        for(int i=0;i<array.length;i++){
            array[i]=input.nextInt();
        }
        System.out.print("Enter number: ");
        int num=input.nextInt();
        for(int i=0;i<array.length;i++){
            if(array[i]<num){
                less++;
            }
            else if(array[i]>num){
                more++;
            }           
        }
        System.out.println("Number of array elements less than "+num+": "+less);
        System.out.println("Number of array elements more than "+num+": "+more);
    }
}









Related Pages:
java program based on array
java program based on array  write a program to create an array of 10 integers in main.accept values from the user in that array .now again ask the use another nomber and pass the array and the no. entered to function called
array and string based problem
array and string based problem  this program is accepting only..._srt(int array[],int n){ for (int j = 0; j < n; j++){ int i = j-1; int k = array[j]; while ((i>= 0) && (array[i] > k)){ array[i
array and string based problem
array and string based problem  this program is accepting only..._srt(int array[],int n){ for (int j = 0; j < n; j++){ int i = j-1; int k = array[j]; while ((i>= 0) && (array[i] > k)){ array[i
array and string based problem
array and string based problem  this program is accepting only..._srt(int array[],int n){ for (int j = 0; j < n; j++){ int i = j-1; int k = array[j]; while ((i>= 0) && (array[i] > k)){ array[i
array program
array program  write a java program which will take 10 elements as command line arguments and count how many times 3 occurs in array
array variable in a java program
array variable in a java program  How do i write a program that will prompt the user for a list of 5 prices, that cosist of the sum of all the prices, the average of the prices, and all prices that are higher than the calculated
array
array  write a program in java which input n ,a natural number less than 12 and prints the natural number from 1 to n to the power 2 in the form of a spiral.the spiral should move in on anti clockwise direction starting from
one dimensional array program
one dimensional array program  Design and implement a java program that will read a file containing numbers and compute the following statistics: the rannge( low, high), the average and the median(middle number). Notes
Java Program
Java Program  Helle can anyone provide me one example... and class instantiation. Write a method that processes a file based on given... that manipulates the data in an array
Array /string based problem....
Array /string based problem....  thanx to help me.but again a problem... or char"); char[] array = new char[5]; for(int i=0;i<5;i++){ char ch=input.next().charAt(0); array[i]=ch; } selectionSort(array); for(int i = 0; i <
string array based problem
string array based problem  R/sir, firstly thanks... string: "); String[] array = new String[5]; for(int i=0;i<5;i++){ array[i]=input.next(); } selectionSort(array); for(int i = 0; i < array.length; i
java 2 d array program
java 2 d array program  write a program 2-d matrix addition through user's input?  Hi Friend, Try the following code: import java.util.*; class MatrixAddition{ public static void main(String[] args
java program
java program  Write a Java program to accept an array list of Employee objects and search for perticular Employee based on Id Number (like ID,Name&Address)   import java.util.Scanner; import java.util.ArrayList
Java array
Java array  Java program to find first two maximum numbers in an array,using single loop without sorting array
Java Array
Java Array   a) Write an array program that perform the following: i) Declares a String array initialized with the following strings: ââ?¬Å...?¬Â?. ii) Write a loop that displays the contents of each element in the array
Two Dimensional Array Program
Two Dimensional Array Program Using Nested for loop       This is a simple Java array  program . In this session we will teach how to use of a two dimensional array
java array
java array  q4.array Write a program that accepts two arrays, an array of fruit names and an array of price of fruits, and a fruit name and returns the price of the fruit. (Assume that a price in the second array corresponds
java array
java array  write a java method that takes an array of float values...)){ System.out.println("There are duplicate elements."); Float array...++){ array[i]=new Float(arr[i]); } Set<Float>
create and use an array variable in a java program
create and use an array variable in a java program  how do i write a program that will prompt the user for a list of 5 prices, once the user has entered all values , your program should compute and display the following: The sum
Three Dimensional Array program
Three Dimensional Array program       This is a very simple Java program. In this program we... the multidimensional array we are going to make a matrix. Now in this program use
Array list java program - Java Interview Questions
Array list java program  Create an employee class with an employee... an employee id is given, display his name & address? Please provide the DETAIL java... we can display his name and address when an employee id is given? i need java
Two Dimensional Array Program
;    This is very simple program of Java. In this lesson we will learn how to display arrange form of two dimensional array program... a integer for array declaration Two dimensional array program. We are going
program of array
program of array  write a program that initializes an array with ten random integers and then prints four lines of output,containing:every element at an even index,every even element,all elements in reverse order,and only
program in array
program in array  print("code sample");write a program that initializes an array with ten random integers and then prints four lines of output...[]=new int[10]; System.out.println("Array of Random Numbers
java program
java program  write a java program to display array list and calculate the average of given array
java program
java program  write a java program to display array list and calculate the average of given array
PHP Array
PHP Array In this page we will learn about PHP Array. We will also understand how to use PHP Array in your PHP program. The PHP Array is very useful in developing PHP based applications. PHP Arrays are ordered map which is used
java program
java program  write a java program to create an array of size 10 by taking input from bufferreader and find out the average of array elements from that array
java program
java program  write a java program to create an array of size 10 by taking input from bufferreader and find out the average of array elements from that array
java program
java program  write a java program to create an array of size 10 by taking input from bufferreader and find out the average of array elements from that array
Array
Array  is it possible to define array like this..? int[] intArray = new int[] {4,5,6,7,8}; Explain...?   Yes, you can. Java Initialize Array
array
array  array memory allocation is dynamic or static in java   Java Arrays have dynamic memory allocation
array
array  take a 2d array and display all its elements in a matrix fome using only one for loop and ple explain the program in below
Array
Array  can we create an array of size 1 lakh in java programming
array
array  WAP in java to store 6 element in array P and 4 element in array Q. Produce the third arra y R containing all element from p & q
Array in Java - Java Beginners
Array in Java  Please help me with the following question. Thank you. Write a program that reads numbers from the keyboard into an array of type int[]. You may assume that there will be 50 or fewer entries in the array. Your
ARRAY TUTORIAL
- It is easy to write outsides the bounds of a String or an array in Java: True or False? If false, explain why. Q2 - In Java, you must declare an array before you... different syntaxes that can be used to declare an array in type int in Java. Q4
ARRAY TUTORIAL
- It is easy to write outsides the bounds of a String or an array in Java: True or False? If false, explain why. Q2 - In Java, you must declare an array before you... different syntaxes that can be used to declare an array in type int in Java. Q4
array password - Java Beginners
array password  i had create a GUI of encryption program that used the array password. my question is can we do the password change program? i mean we change the older password with the new password
array programs
array programs  write a program in java to input 10 numbers in an array and print out the Armstrong numbers from the set.   import... Numbers: "); int array[]=new int[10]; for(int i=0;i<array.length
array programs
array programs  write a program in java to input 10 numbers in an array and print out the Armstrong numbers from the set.   import... Numbers: "); int array[]=new int[10]; for(int i=0;i<array.length
Implementing a SoftReference based HashMap - Java Tutorial
Implementing a SoftReference based HashMap 2001-03-28 The Java Specialists' Newsletter [Issue 015] - Implementing a SoftReference based HashMap Author... either via email or RSS. Welcome to the 15th issue of "The Java(tm
Java Program
Java Program  I want to Write a program in JAVA to display to create a class called MATRIX using a two-dimensional array of integers. Perform the addition and subtraction of two matrices. Help me
JAva program
JAva program  Write a JAva program that takes various string from command line and display them in sorted order.   Java display strings...); System.out.println("Enter 5 strings: "); String array[]=new String[5
array - Java Beginners
array  ..how to make this program?? what is the length of 1st array:5 what is the length of 2nd array:4 enter a number for 1st array: 4 enter a number for 1st array: 6 enter a number for 1st array: 2 enter a number
Array sorting - Java Beginners
Array sorting   Hello All. I need to sort one array based on the arrangement of another array. I fetch two arrays from somewhere... need to sort the "name" array alphabetically. I can do that easily using
array - Java Beginners
array  ..how to make this program?? using import java.io.*; and no function,,, what is the length of 1st array:5 what is the length of 2nd array:4 enter a number for 1st array: 4 enter a number for 1st array: 6 enter
Java Array - Java Beginners
Java Array  Q4-Write a program to exchange the nondiognal elements of a two dimensional array A of size NxN without using any other array ie. each a[i][j]with a[j][i] where i is not equal j?   Hi Friend, Please try
Array in Java
. Different types of array used in Java are One-dimensional, Two-dimensional and multi... an array in a program: Declaration of an Array Construction of an Array Initialization of an Array Arrays in Java for different data
Changing the value of Array in Java
array program is provided Java application program about the explanation... Changing the Value of Array in Java       This is very simple of one dimensional array program

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.