Hi, am trying to create these with my code, but i keep getting this error messag
ID: 3651738 • Letter: H
Question
Hi, am trying to create these with my code, but i keep getting this error message from my hw site Error: Your solution doesn't meet one or more constraints required by this problem.Your solution must have a class constant. A constant must be declared as 'static final' outside of any methods in your class.
can someone help me? and this is my code for both.
size 4
!!!!!!!!!!!!!!
\!!!!!!!!!!//
\\!!!!!!////
\\\!!//////
size 7
!!!!!!!!!!!!!!!!!!!!!!!!!!
\!!!!!!!!!!!!!!!!!!!!!!//
\\!!!!!!!!!!!!!!!!!!////
\\\!!!!!!!!!!!!!!//////
\\\\!!!!!!!!!!////////
\\\\\!!!!!!//////////
\\\\\\!!////////////
public class figures {
/**
* @param args the command line arguments
*/
public static int height =4;
public static int height2 =7;
public static int drawings = ((height*4)-2);
public static int drawings2 = ((height2*4)-2);
public static void main(String[] args) {
for (int line =0; line< height; line ++)
{
for( int i = 1; i<=(2*line); i++)
{
System.out.print("\");
}
for( int j=1; j<=(drawings - (2*(2*line))); j++)
{
System.out.print("!");
}
for( int k = 1; k<=(2*line); k++)
{
System.out.print("/");
}
System.out.println();
}
for (int line =0; line< height2; line ++)
{
for( int i = 1; i<=(2*line); i++)
{
System.out.print("\");
}
for( int j=1; j<=(drawings2 - (2*(2*line))); j++)
{
System.out.print("!");
}
for( int k = 1; k<=(2*line); k++)
{
System.out.print("/");
}
System.out.println();
}
}
}
Explanation / Answer
Try this corrected one:
==================================================
public class figures
{
static final int height =4;
static final int height2 =7;
static final int drawings = ((height*4)-2);
static final int drawings2 = ((height2*4)-2);
public static void main(String[] args) {
for (int line =0; line< height; line ++)
{
for( int i = 1; i<=(2*line); i++)
{
System.out.print("\");
}
for( int j=1; j<=(drawings - (2*(2*line))); j++)
{
System.out.print("!");
}
for( int k = 1; k<=(2*line); k++)
{
System.out.print("/");
}
System.out.println();
}
for (int line =0; line< height2; line ++)
{
for( int i = 1; i<=(2*line); i++)
{
System.out.print("\");
}
for( int j=1; j<=(drawings2 - (2*(2*line))); j++)
{
System.out.print("!");
}
for( int k = 1; k<=(2*line); k++)
{
System.out.print("/");
}
System.out.println();
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.