Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8529605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:04:08+00:00 2026-06-11T09:04:08+00:00

Ok, the title might be deceiving. All i want to do is take my

  • 0

Ok, the title might be deceiving. All i want to do is take my Bingo program and when the second bingo card is printed, i want to replace all the “0”‘s with “X”‘s. I was thinking i would have to go and change the array to an string, but i’m not surer where to start.

Here is the Bingo program:

import java.util.*;
import java.io.*;
import java.util.Arrays;

 public class Bingo
 {
public static final int ROWS = 5;
public static final int COLS = 5;
public static final int VERTICAL = 1;
public static final int DIAGONAL = 2;
public static final int HORIZONTAL = 3;
public static int winFound;
public static int currPick = 0;
public static int randomPick = 0;
public static int WinFound;

public static void main(String[] args)
{   
int Totcards;
int[][] card = new int[ROWS][COLS];
int[] picks = new int[25];

fillCard (card);
printCard(card);
playGame(card);
printCard(card);
finalCard(card);

   }

private static void fillCard (int[][] card)
{
//  FileReader fileIn = new FileReader("Bingo.in");
//  Bufferreader in = new Bufferreader(fileIn);

    try {
    Scanner scan = new Scanner(new File("bingo.in"));
      for (int i=0; i<card.length; i++){
               for (int j=0; j<card[0].length; j++){
                card[i][j] = scan.nextInt();
    }
    }
    } catch(FileNotFoundException fnfe) {
      System.out.println(fnfe.getMessage());
    }

}

private static void printCard (int[][] card)
{
    System.out.println("\n\tYOUR BINGO CARD : ");
    System.out.println("\n\tB    I    N    G    O");
    System.out.println("\t----------------------");

    for (int i=0; i<card.length; i++){
          for (int j=0; j<card[0].length; j++){
              System.out.print("\t" + card[i][j]);
              }
    System.out.print("\n");
    }
}

private static void playGame (int[][] card)
{

    int numPicks = 0;       

    System.out.println("\n\tBINGO NUMBERS PICKED AT RANDOM FROM BIN: ");    
    while (true)
            {
               markCard (card);   // Generate a random num & zero-it out
       winFound = checkForWin(card);  //  Look for zero sums
       numPicks++;

               if (winFound != 0)
               {
        if (winFound == 1)
        {
            System.out.print("\n\n\tYOU WIN WITH A VERTICAL WIN AFTER " + numPicks + " PICKS\n");
        }
        else if (winFound == 2){
            System.out.print("\n\n\tYOU WIN WITH A DIAGONAL WIN AFTER " + numPicks + " PICKS\n");
        }
        else if (winFound == 3){
            System.out.print("\n\n\tYOU WIN WITH A HORIZONTAL WIN AFTER " + numPicks + " PICKS\n");
        }

                 announceWin (numPicks);
                 return;
               }
            }


   }        
private static void markCard (int[][] card)
{
  int randomPick = (int) (Math.random() * 74) + 1;


  for (int j = 0;  j < ROWS;  j++){
        for (int k = 0;  k < COLS;  k++){
            if (card[j][k]==randomPick)
                    card[j][k] = 0;}    
    }
    System.out.print("\t " + randomPick + " ");
System.out.print("");
}

private static int checkForWin(int[][] card)
{
  int sum=0;

   for (int i = 0;  i < ROWS;  i++)
       {
        sum = 0;
        for (int j = 0;  j < COLS;  j++)
        sum += card[i][j];

        if (sum == 0)
            return HORIZONTAL;
       }

       for (int j = 0;  j < COLS;  j++)
       {
         sum = 0;
         for (int i = 0;  i < ROWS;  i++)
            sum += card[i][j];

        if (sum == 0)
            return VERTICAL;
       }

       sum = 0;
       for (int i = 0;  i < ROWS;  i++)
            sum += card[i][ROWS-i-1];
       if (sum == 0)
            return DIAGONAL;

       sum = 0;
       for (int i = 0;  i < ROWS;  i++)
          sum += card[i][i];

       if (sum == 0)
            return DIAGONAL;

       return WinFound;
    } 

private static void makeCard(int[][] card, int[] picks)
{
            int count = 100;
            int currPick = 0;
            for (int i=0; i<count; i++){
             currPick = (int)(Math.random() * 74) + 1;
             System.out.print(" " + currPick + "\n");
    picks[i] = currPick;
            }
}

private static void announceWin(int numPicks)
{

}

private static boolean duplicate (int currPick, int[] picks, int numPicks)
{
    for (int i = 0;  i < numPicks;  i++){
                    if (picks[i] == currPick){
                            return true;}
        }
            return false;

}

private static void finalCard (int[][] card)
{ 
    Arrays.sort(card);
    final String stringRep = Arrays.toString(card);
    final String[] out =
        stringRep.substring(1, stringRep.length() - 1).split("\\s*,\\s*");

    System.out.println(Arrays.toString(out));
}
   }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:04:10+00:00Added an answer on June 11, 2026 at 9:04 am

    Try this:

    System.out.print("\t" + (card[i][j] == 0 ? "X" : card[i][j]))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The title might be confusing. Just say I have a newspaper article. I want
the title might be a little bit confusing, let me explain, ;) I have
I asked a question , title of which might have been misleading so I'm
The title might be vague, but I have a good example: echo Test message:\nThis
The title might be confusing but this is what I want to accomplish. I
The title might have been a bit confusing but I can clarify here. I'm
I might have written a pretty confusing title but my question is rather simple.
This might seem a bit awkward but I want to start a console program
The title might be a bit vague, but what I want is to achieve
The title might be ambiguous, didn't know how else to word it. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.