What is wrong in this? I see that trouble is about using Scanner library,but don't understand what exactly | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is wrong in this? I see that trouble is about using Scanner library,but don't understand what exactly

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner price1 = new Scanner(System.in); Scanner price2 = new Scanner(System.in); int price12= price1.nextInt(); int price22 = price2.nextInt(); int newPrice=price12*2/100; if(newPrice<price22){ System.out.print("Pesos"); } else{ System.out.print("Dollars"); } } }

26th Apr 2022, 3:44 PM
Валерия Котырло
1 Answer
+ 5
You should open und use only one scanner for all inputs.
26th Apr 2022, 3:46 PM
JaScript
JaScript - avatar