* Prints Letter L
*
* @author
* @version 18 August 2009
*/
public class LetterL
{
private int height;
private int width;
public LetterL(int initHeight, int initWidth)
{
height = initHeight;
width = initWidth;
}
public void print()
{
System.out.println(toString());
}
public String toString()
{
String letter = "";
for (int i=2;i<=width;i++)
{
letter += "*\n";
if(i==height)
{
for(int j = 0; j<width; j++)
{
letter += "*";
}
}
}
return letter;
}
}
// I used BlueJ for this, can anyone alter this code so that it would print O and P? (separate classes with LoopTester)
The attached file shows the expected output...
Attached File(s)
-
Loop_expected_output.doc (22.5K)
Number of downloads: 50

New Topic/Question
Reply





MultiQuote









|