This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

How to sum array input.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm new in java and creating a java prog that will display cost of BREAKFAST, LUNCH, and DINNER


The below code is how I have gone so far



My first question is
How do I let this program run accepting input from 3 users with the click on my ADD button to display in the textarea. It runs now but only display my first set of input 3 times

(NOW)
Cost of breakfast=5.50 Cost of lunch=4.80 Cost of dinner=3.50
Cost of breakfast=5.50 Cost of lunch=4.80 Cost of dinner=3.50
Cost of breakfast=5.50 Cost of lunch=4.80 Cost of dinner=3.50

(BUT I WANT)
Cost of breakfast=5.50 Cost of lunch=4.80 Cost of dinner=7.50
Cost of breakfast=7.50 Cost of lunch=9.00 Cost of dinner=6.00
Cost of breakfast=13.00 Cost of lunch=4.50 Cost of dinner=13.50

Question 2:
How do I do get to display with the RESULT button just below the 2D array in the textarea
1. the sum of the amount spent on LUNCH by the 3 users and
2. also the average spent by each person on the 3 meal

Thanks alot.





 
Bartender
Posts: 2481
108
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note to admin, Please move this to the appropriate forum (probably Java general) for a better response,



 
Honk if you love justice! And honk twice for tiny ads!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!