I just started learning arrays and I'm terrible at it! As you can see, I'm doing a coin toss game and I have to make sure the money value corresponds to the coin. Nickle = 0.05, Dime = 0.10, and Quarter = 0.25.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | public static void main (String[] args){ double coinsArray[] = { 0.05 , 0.10 , 0.25 }; String coinName[] = {nickle, dime, quarter}; int coin; String nickle; String dime; String quarter; Coin coinArray[] = new Coin[ 2 ]; Coin nickle[] = new Coin(); coinArray[ 0 ] = nickle; Coin dime[] = new Coin(); coinArray[ 1 ] = dime; Coin quarter[] = new Coin(); coinArray[ 2 ] = quarter; } |