Beri nama Program : timer
import java.text.DecimalFormat;
class timer {
private Thread thread;
public static void main(String[] args) {
int J,M,D;
J=2;
M=30;
D=40;
DecimalFormat format = new DecimalFormat("00");
while (true) {
try
{
Thread.sleep(1000);
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
if(J==0 && M==0 && D==0)
{
System.out.println(J+"0:"+M+"0:"+D+"0");
break;
}
System.out.println(format.format(J)+ ":"+format.format(M)+":" + format.format(D));
if(M != 0) {
if(D == 0) {
M--;
D = 60;
}
} else {
if(D == 0) {
D = 59;
}
}
if(J !=0) {
if(M == 0) {
J--;
M = 59;
}
} else {
if(M == 0) {
M = 0;
}
}
D--;
}
}
}
Tidak ada komentar:
Posting Komentar