Advertisement
ezidan

task11

Dec 27th, 2022
904
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.49 KB | None | 0 0
  1. import 'dart:io';
  2.  
  3. void main() {
  4.   print("Task 11: ");
  5.   print("Please enter a number of seconds:");
  6.   int? secs = int.parse(stdin.readLineSync()!);
  7.   print(intToTimeLeft(secs));
  8. }
  9.  
  10. String intToTimeLeft(int value) {
  11.   int h, m, s;
  12.   String fh, fm, fs;
  13.   h = value ~/ 3600;
  14.   m = ((value - h * 3600)) ~/ 60;
  15.   s = value - (h * 3600) - (m * 60);
  16.  
  17.   h <= 9 ? fh = "0$h" : fh = "$h";
  18.   m <= 9 ? fm = "0$m" : fm = "$m";
  19.   s <= 9 ? fs = "0$s" : fs = "$s";
  20.  
  21.   String result = "$fh:$fm:$fs";
  22.   return result;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement