• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps help.please!

for my school assingment i have to make an android application for a card game-black jack.yes,i have found different and so many source codes on the web but when i copy them in my eclipse there always seems to be an error.
since i don't have time to learn the basis for java NOW(but i will,because i'm very interested in it) i am really hoping that someone can explain me how to make it work.
 
here is one source code:

Code:
package com.bj.android.bj;
 
 import java.io.*;
 
 public class BlackjackActivity
 {
 public static void main(String[] args) throws IOException
 {
 
 BufferedReader dataIn = new BufferedReader (new InputStreamReader(System.in));
 
 //Declare Variables
 int again = 0;
 do
 {
 double range = 26;
 int randomGenNum;
 int kitty = 1000;
 int yourBet;
 int userHandValue = 0;
 int userDrawnValue;
 int dealerHandValue = 0;
 int dealerDrawnValue;
 String playAgain;
 String hit = "";
 String strBetAmount;
 String userCard, dealerCard;
 
 int[] arrayCardValues =  {0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10};
 String[] arrayCardSuites =
 {
 "","","Ace/Clubs","Ace/Diamonds","Ace/Hearts","Ace/Spades",
 "2/Clubs","2/Diamonds","2/Hearts","2/Spades","3/Clubs","3/Diamonds","3/Hearts","3/Spades",
 "4/Clubs","4/Diamonds","4/Hearts","4/Spades","5/Clubs","5/Diamonds","5/Hearts","5/Spades",
 "6/Clubs","6/Diamonds","6/Hearts","6/Spades","7/Clubs","7/Diamonds","7/Hearts","7/Spades",
 "8/Clubs","8/Diamonds","8/Hearts","8/Spades","9/Clubs","9/Diamonds","9/Hearts","9/Spades",
 "10/Clubs","10/Diamonds","10/Hearts","10/Spades","Jack/Clubs","Jack/Diamonds","Jack/Hearts","Jack/Spades"
 ,"Queen/Clubs","Queen/Diamonds","Queen/Hearts","Queen/Spades","King/Clubs","King/Diamonds","King/Hearts","King/Spades"
 };
 
 //ask the user how much they want to bet
 System.out.println("How much do you want to bet?");
 strBetAmount = dataIn.readLine();
 yourBet = Integer.parseInt(strBetAmount); 
 //draw three cards (one card face up for dealer, two for player)
 
 //dealer first drawn card
 randomGenNum = (int)((range * Math.random()) + 1)*2;
 //assigning the dealer hand value & card, pulling index from array
 dealerHandValue = arrayCardValues[randomGenNum];
 //Check if the dealer got an ace
 if ((randomGenNum >= 2) && (randomGenNum <= 5))
 {
 dealerHandValue = dealerHandValue + 10;
 }
 int tempDealerHandValue = dealerHandValue;
 dealerCard = arrayCardSuites[randomGenNum];
 //displaying values to the screen
 System.out.println("The dealer is showing a " + dealerCard);
 //System.out.println("The value is " + dealerHandValue);
 //dealers second drawn card
 randomGenNum = (int)((range * Math.random()) + 1)*2;
 //assigning the dealer hand value & card, pulling index from array
 dealerHandValue = arrayCardValues[randomGenNum];
 //Check if the dealer got an ace
 if ((dealerHandValue != 11) && (randomGenNum >= 2) && (randomGenNum <= 5))
 {
 dealerHandValue = dealerHandValue + 10;
 }
 dealerCard = arrayCardSuites[randomGenNum];
 //displaying values to the screen
 //System.out.println("The dealers second card is " + dealerCard);
 //System.out.println("The dealers total hand value is: " + (tempDealerHandValue + dealerHandValue));
 
 
 
 //users first drawn card
 randomGenNum = (int)((range * Math.random()) + 1)*2;
 //assigning the user hand value & card, pulling index from array
 userHandValue = arrayCardValues[randomGenNum];
 //Check if the user got an ace
 if ((randomGenNum >= 2) && (randomGenNum <= 5))
 {
 userHandValue = userHandValue + 10;
 }
 int tempUserHandValue = userHandValue;
 userCard = arrayCardSuites[randomGenNum];
 //displaying values to the screen
 System.out.println("Your first card is " + userCard);
 
 
 //users second drawn card
 randomGenNum = (int)((range * Math.random()) + 1)*2;
 //assigning the user hand value & card, pulling index from array
 userHandValue = arrayCardValues[randomGenNum];
 //Check if the user got an ace
 if ((userHandValue != 11) && (randomGenNum >= 2) && (randomGenNum <= 5))
 {
 userHandValue = userHandValue + 10;
 }
 userCard = arrayCardSuites[randomGenNum];
 //displaying values to the screen
 System.out.println("Your second card is " + userCard);
 System.out.println("Your total hand value is: " + (tempUserHandValue + userHandValue));
 
 }
 while (again == 1);
 
 }
PLEASE.I'M DESPERATE.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones