Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'dart:io';
- void main() {
- print("Task 11: ");
- print("Please enter a number of seconds:");
- int? secs = int.parse(stdin.readLineSync()!);
- print(intToTimeLeft(secs));
- }
- String intToTimeLeft(int value) {
- int h, m, s;
- String fh, fm, fs;
- h = value ~/ 3600;
- m = ((value - h * 3600)) ~/ 60;
- s = value - (h * 3600) - (m * 60);
- h <= 9 ? fh = "0$h" : fh = "$h";
- m <= 9 ? fm = "0$m" : fm = "$m";
- s <= 9 ? fs = "0$s" : fs = "$s";
- String result = "$fh:$fm:$fs";
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement