Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Daryl Butler   on Dec 14 In Java Category.

  
Question Answered By: Frederick Greene   on Dec 14

May be u can try out this program

import java.io.*;


class Rectangle {
int width;
int height;
/** Creates new Rectangle */
Rectangle(int argWidth, int  argTall) {
width = argWidth;
height = argTall;
}
/** Display's a rectangle */

void show()
{
Length(width);
System.out.println("");
Breadth(height,width);
Length(width);
}

void Length(int l)
{
for(int i=0;i<l;i++)
{
System.out.print("*");
}
}
void Breadth(int b,int l)
{
for(int j =0;j<b;j++)
{
for(int i=0;i<l;i++)
{
if(i==0 || i==l-1)
System.out.print("*");
else
System.out.print(" ");
if(i==l-1)
System.out.print("\n");
}
}
}



public static void  main(String [] args) {
Rectangle aRect = new Rectangle(90,17);
aRect.show();
}
}

Share: