No such element exception!1

Plz look at the code at line no.7. error while using sc.nextInt();

Static scanner will give error , dont use scanner as parameter or multiple Scanners , ( works fine on Eclipse But NoSuchElementException is found on online judge )
there’s no benefit to creating more than one Scanner object. It’s simply reading input from a stream, and having more than one reference to that stream isn’t necessary or beneficial to your operations.

what else to do then

declare 1 scanner for the whole code .

But for 2 different classes how to use one scanner

define one public class main and define scanner then define all the other class and the main function inside that class

Could u review my code and tell if this is the right approach? (output coming now)

yes the last submission that you did, its correct