Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

liliy

  • 2 years ago

how do i create a chess board to look like this: ****** ##### ***** ##### ***** ****** ##### ***** ##### ***** ****** ##### ***** ##### ***** ##### ***** ##### ***** ##### ##### ***** ##### ***** ##### ##### ***** ##### ***** ##### etc...

  • This Question is Closed
  1. liliy
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    in java.

  2. Chris2332
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    - have a flag that will determine whether you print * or # - loop as many times as you need to print * and # and switch the flag after each loop - determine how many rows you want before changing the beginning character that's an initial guide!

  3. liliy
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    if((j%2==0 && i%2==0)||(j%2!=0 && i%2!=0)){ for(int k=0;k<6;k++){ if(a[i]==j) printQ(i); else System.out.print("***************\t###############\t***************\t###############\t***************\t###############\t***************\t###############\n");//****************\t###############\t***************\t###############\t***************\t###############\t***************\t###############\n***************\t###############\t***************\t###############\t***************\t###############\t***************\t###############\n***************\t###############\t***************\t###############\t***************\t###############\t***************\t###############\n***************\t###############\t***************\t###############\t***************\t###############\t***************\t###############\n"); } } if((j%2!=0 && i%2==0)||(j%2==0 && i%2!=0)) for(int k=0;k<6;k++) if(a[i]==j) printQ(i); else System.out.print("###############\t***************\t###############\t***************\t###############\t***************\t###############\t***************\n");//###############\t***************\t###############\t***************\t###############\t***************\t###############\t***************\n###############\t***************\t###############\t***************\t###############\t***************\t###############\t***************\n###############\t***************\t###############\t***************\t###############\t***************\t###############\t***************\n###############\t***************\t###############\t***************\t###############\t***************\t###############\t***************\n"); }

  4. liliy
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    my print Q(i): takes it to antoher method that checks if that "box" should get a special symbol and will replace the * or # with the symbol. but it doesnt work!!!AHHH!!

  5. jon.stromer.galley
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Let's assume for now that we don't want to pass some of our parameters about all over the place and instead we will use some class fields to store info. Specifically: int rows = 8; int cols = 8; int cellHeight = 3; int cellWidth = 5; Now, you might create some functions to perform the work for you: void printBoard() { // we are going to call printRow() "rows" times } void printRow(int currRow) { // a row is actually comprised of cellHeight sub rows // for each subrow we are going to call printCell() "cols" times } void printCell(int currRow, int currCol) { // this cell will print either "*" or # repeated cellWidth times // what does (currRow +currCol ) % 2 give you? }

  6. liliy
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    thank you so much, you really helped. but how do i make it tabbed? wher do i put the \t? because right now its just one long thing going down one collumn. i want it to be a board!:(

  7. jon.stromer.galley
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    you can select a "column separator" either space or tab or whatever and print it as the last thing you do in printCell() Let me know if you would like to see some more of a complete example.

  8. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.