aspose file tools*
The moose likes Beginning Java and the fly likes 2D Array problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "2D Array problem" Watch "2D Array problem" New topic
Author

2D Array problem

Tracey Morohunfola
Greenhorn

Joined: Sep 10, 2010
Posts: 3
I'm new in Java and creating a GUI that accepts 3 users input simultaneously (double values from 3 textfield) .
My array is double array[][] = new array[3][3];

My question is
1. How do I store those 3 inputs on every click of the add button to display as a 2D array in a textArea
2. Also calculate the sum of values in array[0][0], array[1][0], and array[2][0]

Thanks
puneeth poduri
Greenhorn

Joined: Sep 16, 2010
Posts: 6
hi,
please add an action listener to the add button

if button variable is "addButton"

then

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You're asking how to add three numbers together?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38881
    
  23
Don't know why your previous post was overlooked; I suspect you posted it in an inappropriate location. Welcome to the Ranch, even though it is late .

[Pedantic mode]There is no such thing as a 2D array in Java™. Only arrays of arrays.[/Pedantic mode]
Get a piece of paper, and a pencil and (most important ) an eraser, and write down prices [0][0] = 1.23, prices[0][1] = 2.34, prices[0][2] = 3.45, and then add the other rows. Now see if you can work out how to add the three together. Once you see what you are doing, on paper, it will be easy to convert that to code.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38881
    
  23
puneeth poduri wrote:hi,
please add an action listener to the add button . . .
I think you have misunderstood the problem. Look at this thread.
Tracey Morohunfola
Greenhorn

Joined: Sep 10, 2010
Posts: 3
How do I make the program to allow three users to put in their meal prices

If I run this, it only allows one input and displays it as 3 input in the array


 
jQuery in Action, 2nd edition
 
subject: 2D Array problem