ProgramWindowJava

Need help with this Code, please.

I have this program. The output of the program is 揙H?

How to shorten the program but with sticking to the same idea? Meaning, not making major changes to the program. Just having lesser codes

import javax.swing.JOptionPane;

public class HouseB
{
public static void main(String args[])
{
int no_rows;
String str_no_rows;

str_no_rows = JOptionPane.showInputDialog("Enter row numbers (3 or 5):");
no_rows = Integer.parseInt(str_no_rows);

switch (no_rows)
{
case 3: {
print_x(0);
print_x(4);
print_x(0);
break;
}
case 5:
{
print_x(0);
print_x(4);
print_x(4);
print_x(4);
print_x(4);
print_x(4);
print_x(0);
break;
}
default:
JOptionPane.showMessageDialog(null, "Invalid data, Try again!");
break;
}


System.out.println(" ");


switch (no_rows)
{
case 3: {

print_x(4);
print_x(0);
print_x(4);
break;
}
case 5:
{
print_x(4);
print_x(4);
print_x(4);
print_x(0);
print_x(4);
print_x(4);
print_x(4);
break;
}
default:
JOptionPane.showMessageDialog(null, "Invalid data, Try again!");
break;
}
}


public static void print_x(int no_spaces)
{

if (no_spaces==0)
{

System.out.println("******");
}
else

System.out.print("*");

for (int i=0; i<no_spaces; i++)
{
System.out.print(" ");
}

System.out.println("*");
}
}

[Previous] Need help with methods
[Next] Threads

Google


Java

Threads
My first program.
memory address?
executable java file
Bitwise comparison?
Can't figure out Static Error?
Help!! using recursion to search an array
Encrypt / Decrypt homework help
Menus
help!!!!!!!!!!!!!!!
How to access JSpinner's JTextField?
easy questions
recursion/iterator problem
repainting the whole frame??
Help Wih Chessboard Problem
Format US currency
Applet:How do I get a background image.
ArrayList printout?
Get rid of that comma in my JSpinner!!!
calling other classes