I'm not supposed to use loops for this assignment. Just if/else statements.
I'm trying to get the number of inputs(up to a maximum of 8 inputs) from the scanner and adding them to a counter.
For example, if the user enters 1 3 6 4, the counter should equal 4.
import java.util.Scanner;
public class MyPredictionsOfCodeBehaviour {
public static void main(String[] args) {
Scanner userInput = new Scanner(System.in);
System.out.println("Enter some numbers between 1 and 8."0;
int counter = userInput.nextInt();
System.out.println(counter);
userInput.close();
}
}
Aucun commentaire:
Enregistrer un commentaire