yeah
for example.. when you do a scandisk of your hard drive.. do you see that percentage number that goes from 0 to 100? when its 0 it changes to 1 then 2 then 3 when it reaches 9 it adds another digit, so now its 10 11 and so on but on the same place in that line.. can you get it now?
:-/
> please tell me you're not talking about this:
>
> [code]
> for(int i = 0; i <= 100; ++i) {
>System.out.println(i);
> /code]
No, I think he wants each subsequent printed number to overwrite the previous number. So instead of
1
2
3
4
he wants to only show one number at a time when the loop increments. The other number should disappear.
when you use a for like that right... once u start if(i < 10) for example.. then it will print like this:
0
1
2
3
and so on.. right? well i dont want it that way i want it like if it was a percentage bar when u install a program.. you have a bar that ||||||||| increases as the installation goes on.. but u also have a number inside the bar that says in numbers how the installation is going..
check this to see what i'm trying to tell :-/
http://www.java2s.com/Code/CSharpImages/ProgressBarHost.PNG
Am talking about that little number there 10%
> yeah
>
> for example.. when you do a scandisk of your hard
> drive.. do you see that percentage number that goes
> from 0 to 100? when its 0 it changes to 1 then 2 then
> 3 when it reaches 9 it adds another digit, so now its
> 10 11 and so on but on the same place in that line..
> can you get it now?
>
> :-/
Kinda like this?
public class PrintfTest {
public static void main(String[] args) {
for (int i = 0; i < 100; i++) {
System.out.printf("%7d", i);
try {Thread.sleep(100);} catch(InterruptedException swallowMe) {/* gulp */}
System.out.print("\b\b\b\b\b\b\b");
}
}
}
> hey thanks for that website :-D useful too.
>
> but thats not what i want :s i think jenny knows
>
> dammit :-/ am i hard to understand?
Yes. No one knows whether you're talking about a javascript manipulation of a web page, a console application, or a Swing progress bar widget.
lol
ok my bad!!! :-/
its a console application.. the number i want to display has to go from 0 to 100 in the same place where it is .. for example it starts with a 0, then when i increase the number, 0 is erased and 1 shows up in the same place where the 0 was..
now when you get to 9 you are about to change from a 1 digit to a 2 digit number.. 10.. this time the 0 next to the 1 will change to 1 so it will be a 11 and so on.. :-/
> now when you get to 9 you are about to change from a
> 1 digit to a 2 digit number.. 10.. this time the 0
> next to the 1 will change to 1 so it will be a 11 and
> so on.. :-/
So, kinda like this?
public class PrintfTest {
public static void main(String[] args) {
for (int i = 0; i < 100; i++) {
System.out.printf("%7d", i);
try {Thread.sleep(100);} catch(InterruptedException swallowMe) {/* gulp */}
System.out.print("\b\b\b\b\b\b\b");
}
}
}