Results 1 to 4 of 4
- 03-10-2009, 12:41 PM #1
Member
- Join Date
- Oct 2008
- Posts
- 33
- Rep Power
- 0
How can I make a loop, that writes a....
sentence for every 10 line..
I have a account class, and I want it to write out the interest every 15 year instead of each year as it does now..
Here is what I got:
The result it this:PHP Code:class AccountTest{ public static void main(String [] args){ Konto MikeKonto = new Konto(12345, "Mike Tyson", 24, 10); int teller = 0; while (teller < 200){ MikeKonto.renteSats(); System.out.println("Saldo: " + MikeKonto.finnSaldo()); teller++; } } }
26.4
29.0
etc...
What I want is to set the counter aka "teller" to 200 and have a written line only every 15 year or 20, instead of every year..
"Rentesats" generates the rates every year, and is method in my Account class.. Konto means account.
- 03-10-2009, 02:21 PM #2
if( ( loopIndex % 10 ) == zero )
{
print to receive buffer or file();
}Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
- 03-10-2009, 03:16 PM #3
Member
- Join Date
- Oct 2008
- Posts
- 33
- Rep Power
- 0
Ok, cheers..
Ok, thanks... This is what I ended up with:
Thanks alot..PHP Code:Konto MikeKonto = new Konto(12345, "Mike Bob", 24, 10); int teller = 0; while (teller < 250){ MikeKonto.renteSats(); if(teller % 25 == 0){ System.out.println("Saldo: " + MikeKonto.finnSaldo()); teller++; }else{ teller++; } }
- 03-10-2009, 04:45 PM #4
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
Similar Threads
-
How to make a function?
By mephisto772 in forum New To JavaReplies: 5Last Post: 02-23-2009, 09:51 AM -
Make Change
By Black.Ice. in forum New To JavaReplies: 4Last Post: 12-18-2008, 07:12 AM -
Trying to make a GUI program
By GettinGwap in forum New To JavaReplies: 2Last Post: 11-04-2008, 11:37 PM -
files to make jar?
By c0elh0 in forum New To JavaReplies: 4Last Post: 10-31-2008, 12:04 PM -
i need help to make this program
By masaka in forum New To JavaReplies: 2Last Post: 03-23-2008, 01:26 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks