Pass the array please..

Pass the array please..

View Answers

October 5, 2009 at 4:11 PM

Hi Friend,

Try the following code:

import java.text.*;
import javax.swing.JOptionPane;

public class PassTheArrayPlease
{
public static void averageNumbers()
{
double sum=0.0;
double [] array = new double [5];
for (int i=0; i<array.length; i++) {
String input = JOptionPane.showInputDialog("Input Number");
array[i] = Double.parseDouble(input);
sum+=array[i];
}
double average=sum/5;
NumberFormat formatter = new DecimalFormat("#0.000");
System.out.println("Average is:"+formatter.format(average));
JOptionPane.showMessageDialog(null, "Average is: " + formatter.format(average));
}
public static void main(String[] args)
{
PassTheArrayPlease arr=new PassTheArrayPlease();
arr.averageNumbers();
}
}

Thanks

October 6, 2009 at 8:07 AM

Thank u very much..!









Related Tutorials/Questions & Answers:
Pass the array please.. - Java Beginners
Pass the array please..  hi! i'm having problem... them in an array. When finished receiving the numbers, the program should pass the array to a method called averageNumbers. This method should average the numbers
how to pass an array from one jsp to another jsp - JSP-Servlet
how to pass an array from one jsp to another jsp  hi friedns, can any One tell me how to send an array from one jsp to another jsp,pls any one send the code for this.also porvid the code how to retrive the arry in another jsp
Advertisements
please help me to solve this question about array
please help me to solve this question about array  write a program thatt stores vowels (a,e,i,o and u)in an array. Ask the user to enter any.... Please enter character"); else { ch = brr.charAt(0
please please i wanna insertion sort program find calendar to array value (1000,5000,10000), please help me
Insertion sort program find calendar to array value 1000,5000,10000  program find calendar for insertion sort in jfram to array 1000
How to pass Array of string from action class to jsp page
How to pass Array of string from action class to jsp page  this is my action class package login.ipm; import java.sql.*; import java.util.ArrayList; import javax.servlet.http.HttpServletRequest; import
how to pass string array from action class to jsp page? pls reply me.
how to pass string array from action class to jsp page? pls reply me.  how to pass string array from action class to jsp page? pls reply me.  ...); And through your jsp page, get array values. <% try { String[] str = (String
PASS value
PASS value  javascript to pass value to other html file
in_array
in_array  in_array in php
is _array()
is _array()  is _array()   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php $yes = array('Hello', 'World'); echo is_array($yes) ? 'Array
is _array()
is _array()  is_array() in php   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php $yes = array('Hello', 'World'); echo is_array($yes) ? 'Array
Array
the following alternatives: Please type 1 for Twin Seat and Please type 2 for Normal... 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
Array
Array  how can i use elements of an array in a circular form? that is if the searching of the element reach the last elements of the array, then it will start serching from the begining of the 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  What if i will not declare the limit index of an array, how will I declare an array and store values with it using loop?   Hi Friend... Scanner(System.in); int array[]=new int[5]; System.out.println("Enter
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
Array
Array  How do i insert elements into an array up to a limit from...("Enter Range: "); int size=input.nextInt(); int array[]=new int[size]; System.out.println("Enter Array Elements: "); for(int i=0;i<
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
Array  can we create an array of size 1 lakh in java programming
array
array  array memory allocation is dynamic or static in java   Java Arrays have dynamic memory allocation
Pass by Reference - Java Beginners
Pass by Reference  Hi Friends, What is Pass by value and Pass by Reference?can u please explain with examples.is java supports Pass by reference?  Hi Friend, Pass By Value: It refers to pass the variables
array
array  create an array in which no element is duplicate. if duplicate then tell to user duplicate. duplicacy is tell to user during when he enter the element
array
array  create an array in which no element is duplicate. if duplicate then tell to user duplicate. duplicacy is tell to user during when he enter the element
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
accepts a pointer to integer which represents an array of integer.After that this method prints the entire of the array numbers to the monitor. include using std::cout; using std::endl; void printArray(int *array, int count
array
array  How to store the results of mysql query in an array... qurey in array: "select distinct(EMPLID)from tblwork where EMPLID not in (select... store the result in array
array
array  wap to calculate reverse of 10 elements in an array?  ...(); } System.out.print("Array is: "); for(int i=0;i<arr.length;i...(); System.out.print("After reversing, Array is: "); for(int i=arr.length-1;i>=0
Array's
Array's  I have to finish an "order page". that checks 2 dropdown boxes and a set of radio buttons and put the results into a set of textboxes, 1 line at a time, then calculate a total. I know I need to create an array, but I'm
array
array  Hi i have array like {1,2,3,4,,5,5,6,6} then how can i... is an example that store some integers into an array and find the occurrence of each number from the array. import java.util.*; public class SearchNumberOccurrence
array
array  how to getting values and storing values in array by using datainputstream?   Hi Friend, Try the following code:ADS_TO_REPLACE_1...("Array Elements are: "); for(int i=0;i<arr.length;i
ARRAY
ARRAY  CAN SOMEONE HELP ANSWER THIS QUESTION PLEASE Write a program that allows the user to enter the last names of five candidates in a local election and the votes received by each candidate. The program should then output
ARRAY
ARRAY  CAN SOMEONE HELP ANSWER THIS QUESTION PLEASE Write a program that allows the user to enter the last names of five candidates in a local election and the votes received by each candidate. The program should then output
urgent...pleAse help me.....please!
urgent...pleAse help me.....please!  please help me urgent! how can i do dictionary with the use of array code in java, where i will type the word then the corresponding meaning for that word will appear...thanks
java please please help
java please please help  Dear Friends plz help me to complete... HashMap,HashTable....etc.I dont know how to add this string array here b...); for (String[] array : str){ map.put(array[0], array[1]); } Set set
pass method reference in java
pass method reference in java  How to pass method reference in Java
Is Java pass-by-reference?
Is Java pass-by-reference?  Is Java pass-by-reference
create associative array from array javascript
create associative array from array javascript  How to create associative array from an array in JavaScript? Please suggest. Thanks
PHP Pass Post Data
PHP Pass Post Data  How to pass POST data to the PHP-CGI
JavaScript pass arguments
JavaScript pass arguments   How to pass dynamic arguments to the functions in JavaScript
ModuleNotFoundError: No module named 'Pass'
ModuleNotFoundError: No module named 'Pass'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Pass' How to remove the ModuleNotFoundError: No module named 'Pass' error
ModuleNotFoundError: No module named 'Pass'
ModuleNotFoundError: No module named 'Pass'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Pass' How to remove the ModuleNotFoundError: No module named 'Pass' error
you pass a variable by value.
you pass a variable by value.  How do you pass a variable by value... $a = &$b /*--------------Pass By value----------------*/ function add($a) { return ++$a; } add($a); /*---------------Pass by reference
pass radio button values to next page
pass radio button values to next page  how to pass selected radio button values which coming from mysql database to next page using php. Please show me with examples
Passing array element
Passing array element  What about passing an element of an array? If I have array of objects and pass functionA(arr[2]); Then functionA() will get arr[2] as a value type or a reference type
Can I pass a
Can I pass a   Suppose I have servlet named Name.java and there is a variable String name holding a value "Roseindia". I have collected the value to Getname.jsp via ajax. Now how can I pass this value to scriplet without page
array, index, string
array, index, string  how can i make dictionary using array...please help
Array search
Array search  Need a program which performs a searching operation on a one dimensional array called NUM, which is an N-element array stored in a file... for the search operation. he value with one or more of the array items. Search begins
pass parameter names and values
pass parameter names and values  What is the <jsp:param> standard action?   The <jsp:param> standard action is used with <jsp:include> or <jsp:forward> to pass parameter names and values
How to pass an arraylist from servlet to jsp?
How to pass an arraylist from servlet to jsp?  Hello, Can anyone please tell me how to pass an arraylist from servlet to jsp? I have two arraylist one of type String and the other int. How to send both the arraylists from

Ads