+ 1

Why wont Java accept the input integer?

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double pi = 3.14; //your code goes here int r = input.nextInt(); double p = 2 * pi * r; System.out.println(p); } } This is one of the beginner problems and if I define r as the 'sample number' it works for that single instance, but the program wants to input other ones. My issue is that i cant seem to get it to communicate with my code to add its own inputs. Any help would be much appreciated! Best

30th Aug 2021, 8:42 PM
Michael Carr
2 Réponses
+ 5
scanner.nextInt() //not input
30th Aug 2021, 8:57 PM
Hima
Hima - avatar
+ 1
Hima Thank you!
31st Aug 2021, 7:41 PM
Michael Carr