Home Answers Viewqa Java-Beginners one dimensional array using java

 
 


Bukola Adelakun
one dimensional array using java
1 Answer(s)      a year and 3 months ago
Posted in : Java Beginners

design and implement a java program that will read a file containing numbers and compute the following statistics: the range(low,high) the average and the median

View Answers

February 9, 2012 at 5:07 PM


import java.io.*;
class NumbersFile 
{
    public static void main(String[] args) throws Exception
    {
        BufferedReader br=new BufferedReader(new FileReader("numbers.txt"));
        LineNumberReader reader = new LineNumberReader(new FileReader("numbers.txt"));

int data = reader.read();
 int lineNumber=0;
while(data != -1){
     lineNumber = reader.getLineNumber();
}
int array[]=new int[lineNumber];

int k=0;
String st="";
while((st=br.readLine())!=null){
    array[k]=Integer.parseInt(st);
        k++;
    }
    int low = array[0];
    int high = array[0];
    int sum=0;
    for (int i = 1; i < array.length; i++) {
        if (array[i] < low) {
            low = array[i];
        }
        if (array[i]>high) {
            high = array[i];
        }
        sum+=array[i];
    }
    System.out.println("Numbers lie between "+low+" and "+high);
    System.out.println("Average of numbers: "+(sum/array.length));
}

}









Related Pages:
one dimensional array using java
one dimensional array using java  design and implement a java program that will read a file containing numbers and compute the following statistics: the range(low,high) the average and the median
Display tow dimensional array using one for loop in java
Display tow dimensional array using one for loop in java  Display tow dimensional array using one for loop in java
Display tow dimensional array by matrix form using one for loop in java
Display tow dimensional array by matrix form using one for loop in java  Display tow dimensional array by matrix form using one for loop in java
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
Two Dimensional Array Program
Two Dimensional Array Program Using Nested for loop...; program . In this session we will teach how to use of a two dimensional array... are going to make two dimensional array having three row and three columns. 
Two- Dimensional Array - Java Beginners
Two- Dimensional Array  I am new in java programming. I am creating a two-dimensional array. This is my code ** class BinaryNumbers { public static void main(String[] args) { //create a two-dimensional array int ROWS = 21
Three Dimensional Array program
are going to make three dimensional array having multi rows and columns. By using... Three Dimensional Array program   ... will learn how to use three dimensional array. Firstly, we have to define class
Multi-dimensional arrays
. It does, however, supports an array of arrays. In Java, a two-dimensional array 'x' is an array of one-dimensional array. For instance :-   int[][] x...; So far we have studied about the one-dimensional and two
Array in Java
. Different types of array used in Java are One-dimensional, Two-dimensional and multi-dimensional. One-dimensional arrays: int[] i; int[] i = new int[5]; int... of an Array Initialization of an Array Arrays in Java for different data
Two Dimensional Array Program
Two Dimensional Array Program    ... will learn how to display arrange form of two dimensional array program... a integer for array declaration Two dimensional array program. We are going
Two Dimensional array program
Two Dimensional array program  consider a two dimensional array... to elements of the array such that the last element become the first one and the first become the last.let the program output elements of the first array
Two Dimensional Array Program Using Nested For Loop
Two Dimensional Array Program Using Nested For Loop ... dimensional array program. Firstly, we have to define class "TwoDimensional ". We are going to make a integer for array declaration Two dimensional array
Changing the value of Array in Java
Changing the Value of Array in Java       This is very simple of one dimensional array program. In this tutorial you will learn how to change array values. The one dimensional
Declare string array in Java (one and two dimensional)
Declare string array in Java (one and two dimensional... will learn how to declare string array in java. Java provides many ways to declare... dimensional array and two dimensional as well. 1. String arr[] = new String
Arrays -- Multi-dimensional
] | | | +-----+-----+-----+-----+ +-----+ In Java two-dimensional arrays are implemented is a one-dimensional array... the row (which is a one-dimensional array itself), and the second subscript selects... Java NotesArrays -- Multi-dimensional All arrays in Java are really linear
Square Elements of Two Dimensional Array
Square Elements of Two Dimensional Array        This is a simple java program for implementing the two dimensional array program and its square. This session provide you
The Array Palindrome Number in Java
. In this section you will read how to uses palindrome one dimensional array... The Array Palindrome Number in Java   ... to make one dimensional program. For completion the example firstly we have define
Two dimensional array in java
Two dimensional array in java. In this section you will learn about two-dimensional array in java with an example. As we know that array is a collection... dimensional array is defined as an "array of array". In java the element
reverse two dimensional arrays in java
reverse two dimensional arrays in java  reverse array elements in two dimensional array such that the last element becomes the first
how do i begin a two dimensional array?
how do i begin a two dimensional array?  I'm new to java programming and need to create a two dimensional array that enters exactly what is entered in the first dimension and then the first non-white space character of what
php two dimensional array
php two dimensional array  php two dimensional array example
A single dimensional array is called
A single dimensional array is called  What is a single dimensional array called?   A single dimensional array is called LIST
two dimensional - Java Beginners
two dimensional  write a program to create a 3*3 array and print the sum of all the numbers stored in it.  Hi Friend, Try the following code: import java.io.*; import java.util.*; public class matrix
two dimensional array
two dimensional array  how tow dimensional array works.How those loopes get incremented .and how every time the value of k changes
Dividing Element of Two Dimensional Array
Java program.  The java two dimensional array program is operate the two... Dividing  Element of Two Dimensional Array... the output will be displayed by using "System.out.print(" "+(array[i][j]/array1
Creation Time Comparison of Multi Dimensional Array- Java Tutorials
Creation Time Comparison of Multi Dimensional Array In this section, we will compare the creation time between the different size/dimension of array.  As you know that multidimensional array is the array of arrays. Practically
plz try to clear my doubt for shuffling multi-dimensional array
plz try to clear my doubt for shuffling multi-dimensional array  hi, if v r using Arrays.asList() means, it may shuffle the row wise list only... v want to shuffle the ful entire multi-simensional array means wat v want to do
Two-dimensional arrays
; Two-dimensional arrays are defined as "an array of arrays". Since an array type is a first-class Java type, we can have an array of ints... of arrays of  ints". Such an array is said to be a two-dimensional array
Array - Java Beginners
using one-dimensional array that accept five input values from the keyboard...(System.in)); int array[] = {2, 5, -2, 6, -3, 8, 10, -7, -9, 4,15}; Arrays.sort(array); int index = Arrays.binarySearch(array, 2
Multidimensional Array Java
Multidimensional Array Java     ... and multi dimensional array.   In the example given below we have used two dimensional array. A two dimensional array can be thought as a grid
using array
using array  Circular left shift array element by one position
using array
using array  Circular left shift array element by one position
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
Copying an array to another
Java Copy Array Example:In this tutorial, you will learn how to copy data from one array to another. Here, providing you an example with code and its explanation to given below. This is a program that follows one dimensional
Java - Array in Java
Array Example - Array in Java     ... of arrays are used in any programming language such as: one - dimensional, two - dimensional or can say multi - dimensional.  Declaration of an array:  
Array
reserved. Use a one-dimensional array of primitive type Boolean to represent the seating chart of the cinema theater. Initialize all the elements of the array... the corresponding elements of the array to true to indicate that the seat is no longer
need help with two dimensional array that takes input from user and bubble sorts and selections sorts
need help with two dimensional array that takes input from user and bubble... cannot figure out how i can declare a two dimensional array without knowing how... many words he/she types without using an array list.   Thank you. I
Java Multi Dimensions Array - Java Tutorials
is done using array.An array can hold any type of data and can have... below the example to provide you an idea-how array works? Declaring one... DevArray 1.9 2.9 3.4 3.5 Multidimensional array : In java
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
Need coding help - two dimensional matrix and it returns back a boolean.
Need coding help - two dimensional matrix and it returns back a boolean.  I need to write a code method that accepts a two dimensional integer arrays as the argument and returns true if the array or matrix is left or right
Java array - Java Beginners
a program tofind sum of all non dioganal elements of a two dimensional NxN array... array A of size NxN without using any other array ie. each a[i][j]witha[j][i...Java array  Q 1- write a program that counts the frequency
Java Programming using array
Java Programming using array  I'm creating a programming using array that will accept 10 letters and test if those letters are consonant... Program: import java.io.*; public class Array { public static void main(String args
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
PHP Push MultiDimensional Array
a multi-dimensional array into another array, a single element into an array...() is one of the widely used function to add item into an array. General format...-Dimensional Array Example : <?php $array1=$array3=array(1,2,3,4,5,6
Java array
Java array   How can one prove that the array is not null but empty
Hibernate One to many XML mapping array Example
In this section, you will learn how to do one to many mapping using array to retain mapping order in Hibernate
JavaScript array merge
in understanding how to merge two different array into one array using Java Script. We declare a array variable that is used to store array object. An array... JavaScript array merge     
Java array
Java array  Java program to find first two maximum numbers in an array,using single loop without sorting array
using 2D Array
using 2D Array  Write a JAVA program using 2D Array to auto-grade exams. For a class of N students, your program should read letter answers (A, B, C... the class average. Define the exam answer key as Final Array in your program
using 2D Array
using 2D Array  Write a JAVA program using 2D Array to auto-grade exams. For a class of N students, your program should read letter answers (A, B, C... the class average. Define the exam answer key as Final Array in your 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.