• Post Reply Bookmark Topic Watch Topic
  • New Topic

Values not saved into array  RSS feed

 
Roy Poh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For this program I need help to understand why the values are not stored in my arrays:


These are the following thing that i have tried to test whether the value is saved in my array


Somehow the array does not save the value into the array they are able to detect the input but they are not able to save the amount
 
Paweł Baczyński
Bartender
Posts: 2085
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In which place does your output differ from your requirements? What are your requirements? We don't know what your program should do so how can we tell you why it doesn't work as you expect. And we don't know what you expect...
See this link: ItDoesntWorkIsUseless
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roy Poh wrote:Somehow the array does not save the value into the array they are able to detect the input but they are not able to save the amount

Actually, your problem isn't that the values are not stored in the array, it is that you don't read them correctly. What variable are you using to access the amount in the for loop you use to display the results? What variable should you be using?

To help with this sort of thing, you should:
1) Create variables with meaningful names. j, a, x, y are not good names. For example, I might rename j to withdrawlCount. If you do that for all the variables it should be easier to see which values are being used incorrectly.

2) Create variables close to where the are used. a is created at the top of the main method, but used as a for loop counter. Moving it to the for loop helps control its scope, prevents it from being used in incorrect spots and helps define what it is being used for:

Except with a better name, like

 
Roy Poh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel Pawlowicz wrote:In which place does your output differ from your requirements? What are your requirements? We don't know what your program should do so how can we tell you why it doesn't work as you expect. And we don't know what you expect...
See this link: ItDoesntWorkIsUseless


MY requirments are for Array deposit1[i] and Array withdrawal1[j] to be displayed

For example when case 1 is applied


I want the input to be saved into array deposit1[i]

and in the case of case 2,i want the input to be saved into array [j]



and during case 3, i wish to display both arrays with the values that have been inputted in case 1 and case 2


but as seen in the above question, the value does not display no matter the value i type.Why is this so
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!