• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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




 
Bartender
Posts: 5560
213
  • 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
 
What's gotten into you? Could it be this tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic