0

find the mistake

import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; public class ChQ1 { public static void main(String args[]) { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int l=Integer.ParseInt(br.readLine[]); int r=Integer.ParseInt(br.readLine[]); int k=Integer.ParseInt(br.readLine[]); int count=0; if(1<l&&l<=r&&r<=1000&&1<=k&&k<=1000) { for(int i=1; i<=r; i++) { if(i%k==0) { count++; } } System.out.println(count); } } } https://code.sololearn.com/cORlWDn1bR8L/?ref=app

21st Feb 2023, 5:50 PM
Sahil Kshirsagar
Sahil Kshirsagar - avatar
1 Answer
+ 4
It should be like this Integer.parseInt(br.readLine()); Not square brac and parse first letter must be small also wrap your code with try block
21st Feb 2023, 6:49 PM
A S Raghuvanshi
A S Raghuvanshi - avatar