Is there anything wrong | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is there anything wrong

import java.util.Scanner; public class Program { public static void main(String[] args) { String f; double a,b,c; Scanner d=new Scanner(System.in); Scanner e=new Scanner(System.in); a= d.nextInt(); b= e.nextInt(); c=b/0.02; f=(a>b)? "Dollars" : "Pesos"; System.out.println(f); } } Is there anything wrong? I canā€™t find out

14th Apr 2020, 1:47 PM
Zhengrong Yan
Zhengrong Yan - avatar
1 Answer
+ 2
Why two objects for Scanner objects..? No need and not allowed here.... You can use one object through out method.. By declaring class level, you can use in entire class......
14th Apr 2020, 1:59 PM
Jayakrishna šŸ‡®šŸ‡³