Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Creating/ Solving the 8 Queens Problem by Creating Own GUI Chessboard and Messag

ID: 3829011 • Letter: C

Question

Creating/ Solving the 8 Queens Problem by Creating Own GUI Chessboard and Message Display

Hello! I need help with my second big project this semester in my course. The is the second introductry course to Java, so I do not know a lot of advanced programming. To create the GUI, use the Java Swing documentation. The user should be placing the Queens. Also, there should be a tip but (does not have to be using Artificial Intelligence but recommended) that shows the next viable partial solution.

For the second project, you will be combining your knowledge of GUIs and problem solving. In addition there is a bonus aspect that will be your first foray into Artificial Intelligence Like the other project, the TAs nor I will provide no assistance on implementation of the project, rather you can and should ask us concept questions only, which we will be happy to answer. The exception to this is the bonus aspect described below which we can work through and help you design. You w note that the requirements are stated in the voice of a non-technical customer. Thus, you must make many design and implementation choices, which we w then put on our "technical hats" to grade

Explanation / Answer

Due to limitaions i could not put whole code here. Follow following steps for your question

Flag[45]=1 means Queen is placed at cell 45.

int[] flag={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

Create 64 Buttons add following code to each button

8 in each row

following is code for cell no 38

if(flag[38] ==0)
{
jButton38.setText("Q");
flag[38]=1;
}
else
{
jButton38.setText("");
flag[38]=0;
} // TODO add your handling code here:

Code for Partial button:

private void jButton65ActionPerformed(java.awt.event.ActionEvent evt) {

int i=0;
int j=0,notCorrect=0;
int count=0;

for(i=0;i<64;i++)
{
if(flag[i]==1)
{
notCorrect=0;
j=i;
while(j<=64)
{
j=j+9;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
  
}
}
j=i;
while(j>=1)
{
j=j-9;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
  
}
}
if(i>0 && i<=8)
{
j=i;
while(j<=8)
{
j++;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
}
}
while(j>0)
{
j--;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
}
}
}
if(i>8 && i<=16)
{
j=i;
while(j<=16)
{
j++;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
}
}
while(j>8)
{
j--;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
}
}
}
if(i>16 && i<=24)
{
j=i;
while(j<=24)
{
j++;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
}
}
while(j>16)
{
j--;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
}
}
}
if(i>24 && i<=32)
{
j=i;
while(j<=32)
{
j++;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
}
}
while(j>24)
{
j--;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
}
}
}
if(i>32 && i<=40)
{
j=i;
while(j<=40)
{
j++;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
}
}
while(j>32)
{
j--;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
}
}
}
if(i>40 && i<=48)
{
j=i;
while(j<=48)
{
j++;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
}
}
while(j>40)
{
j--;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
}
}
}
if(i>48 && i<=56)
{
j=i;
while(j<=56)
{
j++;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
}
}
while(j>48)
{
j--;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
}
}
}
if(i>56 && i<=64)
{
j=i;
while(j<=64)
{
j++;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
}
}
while(j>56)
{
j--;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
}
}
}
j=i;
while(j<=64)
{
j=j+8;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
  
}
}
j=i;
while(j>=1)
{
j=j-8;
if(flag[j]==1)
{
jLabel1.setText("Not Correct");
notCorrect=1;
break;
  
}
}
if(notCorrect==0)
{
  
count++;
}
else
{
jLabel1.setText("ony " + count + "locations are correect");
break;
}
}
if(count==8)
jLabel1.setText("All locations are correect");
}
// TODO add your handling code here:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote