Hello!
I've been working on this code and it will be really simple. it is supposed to be blackjack look a like but with 1 player that puts in 2 numbers and the one closest to 21 will be presented as winner. Anyone have som ideas to complete this code. i have 1 compilator which is keyboard.class
Anyway, here it is.
''tal1'' is just a name for one of the numbers to put in. And so far it displays the proper winner if i enter number 21. but ''tal1'' always win no matter which numbers i put in. The thing i want is. i mount a number in booth 'tal1' and 'tal2' and the one closest to 21 is printed out as a winner. It shouldnt be that hard but i am not very good yet.//Blackjack public class Blackjack{ public static void main(String[] args){ System.out.print("Skriv in tal 1. "); double tal1 = Keyboard.readDouble(); System.out.print("Skriv in tal 2. "); double tal2 = Keyboard.readDouble(); if (tal1 == 21 && tal2 != 21){ System.out.println("Tal 1 vann"); } else if (tal2 == 21 && tal1 != 21){ System.out.print("Tal 2 vann"); } else if (tal1 < 21 && 21 < tal2){ System.out.print("Tal 1 vann"); } else { System.out.print("tal1 vann"); } } }
Any help is much appreciated :]