+ 2

Why?????

import java.util.Scanner; public class mainNim { static void winningOrLosingStragetyInNim () { Scanner X = new Scanner(System.in); System.out.println("Please enter how many heaps there are"); int Heaps = X.nextInt(); int[] heapStacks = new int[Heaps]; System.out.println("You entered " + heapStacks.length); System.out.println ("Would you like to continue?"); System.out.println("Please write \"yes\" if you would like to continue "); System.out.println("E

26th Dec 2017, 1:55 AM
Victor
Victor - avatar
5 Antworten
+ 5
Sololearn's playground takes all input at once,it cannot take input at runtime sorry
25th Dec 2017, 10:08 PM
David Akhihiero
David Akhihiero - avatar
+ 5
@yerucham I used eclipse to run the program, but it doesn't wan't to run properly in eclipse. I forgot to mention that at the time I posted my question. @Jamie ok I'll do that in the future.
25th Dec 2017, 10:35 PM
Victor
Victor - avatar
+ 1
import java.util.Scanner; public class mainNim { static void winningOrLosingStragetyInNim () { Scanner X = new Scanner(System.in); Scanner D = new Scanner(System.in); System.out.println("Please enter how many heaps there are"); int Heaps = X.nextInt(); int[] heapStacks = new int[Heaps]; System.out.println("You entered " + heapStacks.length); System.out.println ("Would you like to continue?"); System.out.println("Please write \"yes\" if you would like to continue "); System.out.println("Enter \"no\" if you would like to start over"); String continue1 = X.nextLine(); while (!continue1.equals("yes")) { switch(continue1) { case "no": winningOrLosingStragetyInNim(); break; default: System.out.println("Please enter a valid option. You entered" + continue1); System.out.println("Please write \"yes\" if you would like to continue. Enter \"no\" if you would like to start over"); continue1 = D.nextLine(); } } } public static void main(String[ ] args) { winningOrLosingStragetyInNim(); } }
25th Dec 2017, 10:34 PM
Victor
Victor - avatar