0

What can i fill the code for working it? how package used for the code? is it depend on address of it even in app sololearn?

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); //your code goes here } }

1st Dec 2020, 5:49 AM
Behzod
Behzod - avatar
1 Answer
0
What you're supposed to type there depends on what your assignment is asking you to do. The top line: import java.util.Scanner; Utilizes the Scanner class in java. The scanner class is used to take user input. Scanner scanner = new Scanner(System.in); Creates an instance of javas Scanner class to a variable named "scanner". int amount = scanner.nextInt(); Creates a variable called amount. The value of amount ( scanner.nextInt() ), calls the scanner variable you created. nextInt() is a method in javas Scanner class that will prompt for input from the user and saves whatever integer they input into your variable "amount". So whatever the user enters will be saved to the variable you created called "amount" using the Scanner class. The rest depends on what your assignment asks
1st Dec 2020, 6:48 AM
Dustin James Locey
Dustin James Locey - avatar