Back to Problem Solutions forum
long n=sc.nextLong(); long m; String s; int u=0; do{ s=sc.next(); m=sc.nextLong(); if(s.equals("+")) n=n+m; else if(s.equals("")) n=nm;
}while(!s.equals("%"));
System.out.println(n%m+" ");
I didn’t know where the error was. Please help me
Hi Azizbek!
This task is specially invented to teach people avoid some common mistake. So it would be much better if you could find this mistake yourself :)
I recommend to add printing of n
on every iteration, so you can easily see when mistake happens.