Two things to do (generally speaking): 1) change your main class - you are checking winner before first move and after last move... So game for should looks like this: for (i = 0; i < 9; i++) { if (KollaVinst(spelplan)) { break; } else { CheckMove(spelplan, rad, kolumn); }...
To generate the mean value, add up all values in your list and devide them by the number of values: public static void meanArray() { double result = 0; for(int i : list) { result += i; } result /= list.length; System.out.println(result); } ...
I just needed to change the SQL query string to below in order to pass the parameters! Doh! String sql = "SELECT * from operators where user_name = ? and pass_word = ?"; ...
Put your input request in a while statement, check if it's an int, if not repeat the loop, otherwise exit. Do it for both your inputs. Something like this public static void main(String[] args) { String input=null, inputs=null; int input1 = 0, input2=0; boolean err=true; do{ try{ input = JOptionPane.showInputDialog("Enter...
I would create a class Bag with two Items public class Bag { Item item1; Item item2; } public class Item { <any item properties here> } ...
Try the below code to take the array size from user and then user input elements: public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.println("Hur många nummer ska din lista bestå av?"); int ListaLength = s.nextInt(); Integer array[] = new Integer[ListaLength]; for (int i = 0; i < ListaLength;...