Find a subscriber

Report a typo

The call_stat.txt file contains information about mobile subscriber calls. It has the following structure: subscriber_id1 subscriber_id2 duration_sec.

Subscriber ids are String, and duration is Int. For example:

sub1 sub2 72
sub2 sub1 35

Find all the calls that lasted more than 60 seconds and print the corresponding subscriber_id1 to the console. Call duration in the file is given in seconds.

Construct a program that solves the problem. Use single point for tabulation. Three closing curly brackets are collapsed together for simplicity. No need to use tabulation before them.

Reorder lines using drag or arrows. Adjust indentation with left buttons
                val second = scanner.next()
              
                println(first)
              
                val first = scanner.next()
              
                val duration = scanner.nextInt()
              
                Scanner(File("call_stat.txt")).use { scanner ->
              
                while (scanner.hasNext()) {
              
                if (duration > 60) {
              
                }}}
              
___

Create a free account to access the full topic