Pada kesempatan kali ini saya akan membagikan tentang gimana cara membuat jam yang menghitung mundur, . .
Selamat mencoba, . .
import java.util.Scanner;
public class ClockCountdown {
public static void main(String[] iriahus) {
@SuppressWarnings("resource")
Scanner s = new Scanner(System.in);
System.out.print("Enter the number of seconds: ");
int second = s.nextInt();
System.out.println("Start counting...\n");
long lastSec = 0;
while (second >= 0) {
long sec = System.currentTimeMillis() / 1000;
if (sec != lastSec) {
if (second < 2)
System.out.println(second + " second remaining\n");
else
System.out.println(second + " seconds remaining\n");
lastSec = sec;
second--;
}
}
}
}
Semoga bermanfaat, ..
0 Response to "Menghitung Waktu Mundur"
Post a Comment