Results 1 to 3 of 3
- 04-24-2008, 04:01 AM #1
Member
- Join Date
- Apr 2008
- Posts
- 3
- Rep Power
- 0
A problem in practicing the array
The question is :ask the array size
allocate space call method1
ask user for a four digit number
Method 1: filled up the array with four digit random number
Method 2: check if the number is in the array
call method 2 display if the number user input is in the array and at which array
My job stops at:
import javax.swing.JOptionPane;
public class inClassArray
{
public static void main(String[] args)
{
double[] array;
String arraySizeString = JOptionPane.showInputDialog(null,"Please enter the size of array:");
int arraySize = Integer.parseInt(arraySizeString);
String num1String = JOptionPane.showInputDialog(null,"please enter a four-digit number:");
double num1 = Double.parseDouble(num1String);
for(int i = 0; i < arraySize; i++)
{
String stringRandomNum= JOptionPane.showInputDialog(null,"Please input the four-digit number to allocate in the array" + (i+1));
array[i] = Double.parseDouble(stringRandomNum);
}
public static double sameNum(double[] array)
{
for ( int i = 0; i < arraySize; i ++ );
if
num1 = array[i];
return
}
}
}
can anyone help me?really appreciate!!!
- 04-24-2008, 04:28 AM #2
Maybe your question is
What is the problem on your code?can anyone help me?freedom exists in the world of ideas
- 04-24-2008, 11:32 PM #3
Member
- Join Date
- Nov 2007
- Posts
- 20
- Rep Power
- 0
Similar Threads
-
array problem
By oceansdepth in forum New To JavaReplies: 3Last Post: 04-05-2008, 02:25 AM -
Array problem.. help needed please!
By SCS17 in forum New To JavaReplies: 3Last Post: 03-06-2008, 10:30 PM -
Array List Problem
By khamuruddeen in forum New To JavaReplies: 1Last Post: 12-22-2007, 08:10 AM -
array problem
By wats in forum New To JavaReplies: 1Last Post: 12-12-2007, 07:08 AM -
array problem
By Albert in forum Advanced JavaReplies: 2Last Post: 07-01-2007, 01:13 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks