• Post Reply Bookmark Topic Watch Topic
  • New Topic

Having one issue with my assignment, help would be very appreciated.  RSS feed

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an assignment that requires me to modify my last assignment to include a GUI which will display all of the information from previous assignments. Well I have gotten as far as creating the GUI and populating it with the items. However, when it comes to calculating the total at the end, I can't seem to figure out how to get it done, and knowing my luck it's likely to be something simple.






Image doesnt load for myself so heres the link as well:

Link
 
Sheriff
Posts: 4931
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Rande,

Please describe your problem more precisely, as "when it comes to calculating the total at the end, i can't seem to figure out how to get it done" doesn't say a lot what actual problem is.

Also would be great if you would specify the lines, where your code doesn't work as you expect.
 
Rande Fisher
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an idea that the problem is in this line right here.



There is a dialog box in right hand corner of the GUI which is suppose to display the total value of the inventory of the phones. I for some reason can't use the variable i instead of the index number. it for some reason tells me that it can't find the symbol when I do change it, however everywhere else that uses the same variable works fine.
 
Liutauras Vilda
Sheriff
Posts: 4931
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On your specified line

i cannot be resolved to a variable, because i is initialised within the for loop at line 39.
i is accessible within the for loop body, which is being closed at line 44.
You're trying to use variable i at line 60.
 
Liutauras Vilda
Sheriff
Posts: 4931
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does it helps to understand where the issue is and how to solve it?
 
Rande Fisher
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you could give me an idea where to go from here that would be fantastic. I'm trying different methods which I think could work and it's still not getting solved. Tried putting that part of the GUI in a loop with the equation for the total and that didn't work, Last case scenario if I'm not mistaken I could probably hard code the math to add the total values among each index, I was just trying to keep it neater by avoiding
 
Liutauras Vilda
Sheriff
Posts: 4931
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rande,

I don't know your assignment requirements, but it's not important.

Your specified problem at the moment is, that "i" cannot be resolved to a variable at line 60.
I pointed out why is it happens.

Try to solve this problem first, then we can go to another, if there are some.
 
Liutauras Vilda
Sheriff
Posts: 4931
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These assignments in those days are crazy, requirements are based on making the graphical user interface, which doesn't help to master solving the problems of logic itself.
 
Rande Fisher
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it fixed, thank you for pointing me in the right direction. Put a loop around the statement and stopped trying to pull it from the array. Put it in this way:


and it works. much appreciated
 
Liutauras Vilda
Sheriff
Posts: 4931
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome. Good luck with your assignment.
 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you resetting the display every time you get a value from your List? Or are you doing all the additions and resetting the text field with the total once?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!