Can anyone correct this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
3rd Aug 2018, 6:06 PM
Purab Gupta
Purab Gupta - avatar
3 Answers
+ 2
You need to use Scanner instead of DataInputStream. You can find information about it in the SoloLearn Java course
3rd Aug 2018, 7:16 PM
ReimarPB
ReimarPB - avatar
3rd Aug 2018, 7:16 PM
ReimarPB
ReimarPB - avatar
+ 1
Two issues issue 1: DataInputStream Br = new DataInputStream(System.in); Incorrect way to get input, if you want to use inputstream change this into BufferedReader Br = new BufferedReader(new InputStreamReader(System.in)); issue 2: perc = sum/500*100; (did you mean to divide by 400) unless this comes out to a whole number it will convert into 0 Remove int perc from line 5 and create it as a double instead
3rd Aug 2018, 7:14 PM
JME