• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

2D Array problem

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
please add an action listener to the add button

if button variable is "addButton"

then

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're asking how to add three numbers together?
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


 
reply
    Bookmark Topic Watch Topic
  • New Topic