Bukola Adelakun
one dimensional array using java
1 Answer(s)      4 years and 7 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

Ads

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 Tutorials/Questions & Answers:
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
Advertisements
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 - 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
Declare string array in Java (one and two dimensional)
Declare string array in Java (one and two dimensional... program also teaches you how to declare two dimensional array in Java... will learn how to declare string array in java. Java provides many ways to declare
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
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 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
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
two dimensional array  how tow dimensional array works.How those loopes get incremented .and how every time the value of k changes
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
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
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
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 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
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
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
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
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
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
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
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
Java Programming using array
Java Programming using array  I'm creating a programming using array... Program: import java.io.*; public class Array { public static void main(String args...','H','J','K','L','M','N','P','Q','R','S','T','V','W','X','Y','Z'}; char ch
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
using array
using array  Circular left shift array element by one position
using array
using array  Circular left shift array element by one position
Execute the java program using one processor
Execute the java program using one processor   Write a program to print the number series 1, 2,3, 4ΓΆβ?¬Β¦.100 using java programming language in dual core computer a) Execute the program using one processor b) Execute
How to using Binary Search Array Java ?
How to using Binary Search Array Java ?  Hi, I am beginners in Java Programming Language. I am trying to create small application using Array functions. The problem is that how to use binary search array in Java. Please give
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

Ads

Advertisement