0
Why is it showing me error while assigning nextIn()
public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Please enter a number"); int number =s.nextInt(); int sum =0; while (number!= -1) { sum +=number; System.out.println("Please give a number"); number=s.nextInt();} System.out.println("Sum of output is : " +sum); } }
1 Answer
+ 1
You use "s.nextInt" but the scanner is declared as "scan" then you would use "scan.nextInt"