This week's book giveaway is in the Testing forum.
We're giving away four copies of Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples and have Jeremy Kubica on-line!
See this thread for details.
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Homework help

 
Greenhorn
Posts: 24
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the code below...I am not asking for you guys to solve it for me, but to helpgive me advice on where to start looking so I can learn to solve it on my own.

 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Matthew,

What is giving you trouble?
 
matthew meltzer
Greenhorn
Posts: 24
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first question is the one i'm working on right now. Basically when you compile the code it shows 0.00 instead of the 500.00 it should.

I'm guessing the reason for this is because it's outputting information of a new account instead of the user1 account. Because I put in code to print out the other info (the persons name, info, etc) and it comes out as null which shows theres no values set to what is being printed.

So now that i know that it is printing out the information from a new account how do I get the code to print the information from user1 instead of the default values of a new account?
 
Author
Posts: 38
jQuery
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to match the user1 in main with the user1 in createAccount, either by passing the former in or the latter out.
 
Bartender
Posts: 612
7
Mac OS X Python
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why dont you ask your instructor in class? I ask as i teach.
 
matthew meltzer
Greenhorn
Posts: 24
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Keith Wood wrote:You need to match the user1 in main with the user1 in createAccount, either by passing the former in or the latter out.



Could you give an example?

And The reason why I posted here instead of asking my instructor is because My professor usually takes a few days to reply to messages and the assignment is due tomorrow night. It is an online class so it makes communication a little more difficult.
 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

matthew meltzer wrote:

Keith Wood wrote:You need to match the user1 in main with the user1 in createAccount, either by passing the former in or the latter out.



Could you give an example?

And The reason why I posted here instead of asking my instructor is because My professor usually takes a few days to reply to messages and the assignment is due tomorrow night. It is an online class so it makes communication a little more difficult.



The User object (user1) at line 55 is not the same as line 61. The User object created in createAccount() is in local scope and is not the one that is being used to retrieve the balance.
Just to make your desired output, try removing line 61 and replace line 56 with and line 60 with

As for your overall code , I see a lot of flaws, like most of your methods are static. Also, you are passing the User object as parameter to retrieve the balance, while you are using the same object to call the method.

Try utilizing the principles of OOPS.
All The Best!!!
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

matthew meltzer wrote:Here is the code below...


Matthew.

You may notice that your thread is very tough to read; and that's because your code lines are far too long. I suggest you read the UseCodeTags (←click) page again thoroughly, and then use the 'Edit' key to break them up. I'd do it myself, but there are TONS of them.

It's also bad general coding practise.

Winston
 
matthew meltzer
Greenhorn
Posts: 24
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vishal Shaw wrote:

matthew meltzer wrote:

Keith Wood wrote:You need to match the user1 in main with the user1 in createAccount, either by passing the former in or the latter out.



Could you give an example?

And The reason why I posted here instead of asking my instructor is because My professor usually takes a few days to reply to messages and the assignment is due tomorrow night. It is an online class so it makes communication a little more difficult.



The User object (user1) at line 55 is not the same as line 61. The User object created in createAccount() is in local scope and is not the one that is being used to retrieve the balance.
Just to make your desired output, try removing line 61 and replace line 56 with and line 60 with

As for your overall code , I see a lot of flaws, like most of your methods are static. Also, you are passing the User object as parameter to retrieve the balance, while you are using the same object to call the method.

Try utilizing the principles of OOPS.
All The Best!!!



Thank you! The code is from a homework assignment, I'm just supposed to edit it in response to the questions. BUt your post was very informative, thank you.

Winston Gutkowski wrote:

matthew meltzer wrote:Here is the code below...


Matthew.

You may notice that your thread is very tough to read; and that's because your code lines are far too long. I suggest you read the UseCodeTags (←click) page again thoroughly, and then use the 'Edit' key to break them up. I'd do it myself, but there are TONS of them.

It's also bad general coding practise.

Winston



Thanks for the advice. I'm new to posting code on message boards, but that makes alot of sense. I'll use that from now on.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic