Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.potato.applications;
- import java.util.Random;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- int suitpsn, suitcmp, nmbrpsn, nmbrcmp=0, nmbr2psn;
- int nmbr2cmp = 0;
- int nmbr3psn = 0;
- int nmbr4psn = 0;
- int nmbr5psn = 0;
- int nmbr3cmp = 0;
- int nmbr4cmp = 0;
- int nmbr5cmp = 0;
- int nmbr6cmp = 0;
- int nmbr7cmp = 0;
- int nmbr8cmp = 0;
- int nmbr9cmp = 0;
- int input1 = 0;
- int input2 = 0;
- int input3 = 0;
- int psnsuml = 0;
- int cmpsum = 0;
- int counter=2;
- int nxtcrd=0;
- Random r = new Random();
- Random r2 = new Random();
- nmbrpsn = 2 + r2.nextInt(14);
- if (nmbrpsn >= 12) {
- nmbrpsn = 10;
- }
- nmbrcmp = 2 + r2.nextInt(14);
- if (nmbrcmp >= 12) {
- nmbrcmp = 10;
- }
- nmbr2psn = 2 + r2.nextInt(14);
- if (nmbr2psn >= 12) {
- nmbr2psn = 10;
- }
- nmbr2cmp = 2 + r2.nextInt(14);
- if (nmbr2cmp >= 12) {
- nmbr2cmp = 10;
- }
- cmpsum += nmbrcmp + nmbr2cmp;
- System.out.println(" You drew " + nmbrpsn + " and " + nmbr2psn);
- System.out.println("The computer has a " + nmbrcmp);
- Scanner user = new Scanner(System.in);
- if(nmbrpsn + nmbr2psn > 21) {
- System.out.println("You busted. Game over.");
- } else {
- System.out.println(" Do you want another card? 1 is yes 2 is no");
- input1=user.nextInt();
- if (input1 == 1) {
- nmbr3psn = 2 + r2.nextInt(14);
- if (nmbr3psn >= 12) {
- nmbr3psn = 10;
- }
- System.out.println("You drew " + nmbr3psn);
- if(nmbrpsn + nmbr2psn + nmbr3psn > 21) {
- System.out.println("You lose.");
- }else {
- System.out.println(" Do you want another card? 1 is yes 2 is no");
- input2 = user.nextInt();
- if (input2 == 1) {
- nmbr4psn = 2 + r2.nextInt(14);
- if (nmbr4psn >= 12) {
- nmbr4psn = 10;
- }
- System.out.println("You drew " + nmbr4psn);
- if(nmbrpsn + nmbr2psn + nmbr3psn + nmbr4psn > 21) {
- System.out.println("You lose.");
- } else {
- System.out.println(" Do you want another card? 1 is yes 2 is no");
- input3=user.nextInt();
- if (input3 == 1) {
- nmbr5psn = 2 + r2.nextInt(14);
- if (nmbr5psn >= 12) {
- nmbr5psn = 10;
- }
- System.out.println("You drew " + nmbr5psn);
- if(nmbrpsn + nmbr2psn + nmbr3psn + nmbr4psn + nmbr5psn > 21) {
- System.out.println("You lose.");
- }
- }
- }
- }
- }
- }else {
- if (cmpsum > 21) {
- System.out.println("The dealer busted. You win.");}
- else {
- while (cmpsum < 16) {
- nxtcrd = 2 + r2.nextInt(14);
- if (nxtcrd >= 12) nxtcrd = 10;
- cmpsum += nxtcrd;
- System.out.println("The computer drew a " + nxtcrd);
- }
- }
- }
- }
- System.out.println("The computer drew a " + nmbr2cmp);
- System.out.println("Your total is " + (nmbrpsn + nmbr2psn + nmbr3psn + nmbr4psn + nmbr5psn));
- System.out.println("Dealer total is " + cmpsum);
- if(nmbrpsn + nmbr2psn + nmbr3psn + nmbr4psn + nmbr5psn > cmpsum && nmbrpsn + nmbr2psn + nmbr3psn + nmbr4psn + nmbr5psn < 22) {
- System.out.println("Your total was greater. You win.");
- }else {
- System.out.println("The dealer wins.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement