This week's giveaway is in the Java in General forum.
We're giving away four copies of Java Challengers and have Rafael del Nero on-line!
See this thread for details.
Win a copy of Java Challengers this week in the Java in General 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

negating an entry in a list

 
Ranch Hand
Posts: 335
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So  I have a method withdraw that just adds the amount of the withdraw to the list. So if then enter 400 to withdraw I just add that to the list. However when I print the list I want the withdraw to be negative. So the user enters a positive number, and when it prints I want it to be negative. This is what I have

Got more to do, but right now thats my focus




 
Saloon Keeper
Posts: 4383
163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Cody,

what about a simple

What about creating a Transaction class, with fields TransactionType (that could be an enum), the amount involved and the date and time of the Transaction.
That would enable to do some interest calculations, given a list of periods and the interest rate in that period.
 
Cody Biggs
Ranch Hand
Posts: 335
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yea, I figured that out last night. The first thing my mind wants to do is research for some kind of special method out there instead of just looking at it and take a simple approach. I do have have a menu in my Main class that allows for withdraw, deposit, check the balance, and calculate interest. As far as creating the other classes the instructor just wanted something simple, this is the first assignment of the class so its more of just to get us transitioning from java to c#
 
Cody Biggs
Ranch Hand
Posts: 335
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am screwing myself right now though. So I want to add my transactions together to get the balance, and add that to my list. I think I just confused myself so bad. So here is my method



I want to add all the transactions in the list to the balance variable. So thats adding i to balance. so obviously += is wrong because that will add the starting balance twice, and because im returning balance that will return balance + balance, but im printing two number somehow. I get the balance + balance, but then it also prints my deposit to that balance + balance. I have been testing it with just a deposit from my menu
 
Cody Biggs
Ranch Hand
Posts: 335
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fixed it. Nothing to do with balance
 
This is my favorite show. And this is my favorite tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic