-
Notifications
You must be signed in to change notification settings - Fork 0
/
NumberPrinter.java
33 lines (29 loc) · 908 Bytes
/
NumberPrinter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.*;
class NumberPrinter extends TimerTask {
double n;
public NumberPrinter(double toPrint) {
n = toPrint;
}
public void run() {
System.out.println(n);
}
public static void main(String[] args){
if(args.length == 3){
float numberToPrint = Float.parseFloat(args[0]);
int startTime = Integer.parseInt(args[1]);
int interval = Integer.parseInt(args[2]);
Timer timer = new Timer();
timer.schedule(new NumberPrinter(numberToPrint), startTime*1000, interval*1000);
Scanner sc = new Scanner(System.in);
while(true){
if(sc.next().equals("q")){
timer.cancel();
break;
}
}
}
else{
System.out.println("Error, needs 3 arguments");
}
}
}