Assignemnt #89 Cards

Code

    /// Name: Caelan Dorstad
    /// Period: 6
    /// Program Name: card
    /// File Name: card.java
    /// Date Finished: 2/25/2016
    
    import java.util.Random;

    public class card{
        public static void main(String[] args){
            int[] cards = new int [4];
            
            Random r = new Random();
            
            for ( int n = 0; n < 4; n++){
                cards[n] = r.nextInt(10)+1;
            }
            
            System.out.println("You");
            System.out.println("Card 1: "+ cards[0]+ "  Card 2: "+ cards[1]);
            System.out.println("Total: " + (cards[0]+cards[1])+". ");
            
            System.out.println();
            
            System.out.println("Dealer");
            System.out.println("Card 1: "+ cards[2]+ "  Card 2: "+ cards[3]);
            System.out.println("Total: " + (cards[2]+cards[3])+". ");
            
            
            if ( (cards[0]+cards[1]) > (cards[2]+cards[3])) System.out.println("You won!");
            else if ( (cards[0]+cards[1]) < (cards[2]+cards[3])) System.out.println("You lost!");
            else  System.out.println("Draw!");
        }
    }
            
                               

    

Picture of the output

Assignment 10