Results 1 to 2 of 2
- 04-08-2008, 04:56 AM #1
Member
- Join Date
- Apr 2008
- Posts
- 1
- Rep Power
- 0
printing an "E" out of asterisks via strings
the users inputs the height/width for an "E" that's gonna be drawn out of asterisks. the height must be at least 5 asterisks and the width must be at least 4. Should a value less than than 4 for the width or 5 for the height be entered, they default to 4/5 respectively. Should the height be an even #, the "E" must look like this: (middle line above the median)
*****
*
*****
*
*
*****
otherwise, it will look like this:
****
*
****
*
****
It should have a toString() method that returns the E as a string. Here is what I have so far for the code
public class LetterE
{
private int width;
private int height;
public void letterE( int aWidth, int aHeight )
{
if (aWidth =< 4 && aHeight >=5)
{
width = 4;
height = aHeight;
}
if (aWidth >= 4 && aHeight =< 5)
{
width = aWidth;
height = 5;
}
if (aWidth >= 4 && aHeight >= 5)
{
width = aWidth;
height = aHeight;
}
public String toString()
{
???
}
public void print()
{
???
}
}
can anyone help me out w/ what the "???" are supposed to be?
- 04-08-2008, 05:45 AM #2
Welcome to the Java Forums!
Please read the FAQ when you get a chance, there's some helpful information there. What often helps when reading code is to post your code with [ code] [ /code] tags.
Your topic has been discussed before- please do a search for "asterisks" and you'll come up with a few responses. Particularly one where output was to be of a triangle. You can probably deduce how to do an E from that.
Take note that we're here to provide assistance- not doing homework for folks. Make an attempt at your toString and print methods and we can critique or correct your efforts. Help yourself before we help you.Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? Vote now!
Got a little Capt'n in you? (drink responsibly)
Similar Threads
-
Hwlp with "Open", "Save", "Save as..."
By trill in forum New To JavaReplies: 3Last Post: 11-02-2010, 09:26 AM -
failure at Class.forName("oracle.jdbc.driver.OracleDriver");
By RonNYC in forum EclipseReplies: 1Last Post: 03-14-2008, 02:51 PM -
Exception in thread "main" java.net.ConnectException: Connection timed out
By osval in forum Advanced JavaReplies: 1Last Post: 07-27-2007, 10:59 PM -
Error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
By romina in forum New To JavaReplies: 1Last Post: 07-25-2007, 10:55 PM -
ArrayList: Exception in thread "main" java.lang.NullPointerException
By susan in forum New To JavaReplies: 1Last Post: 07-16-2007, 06:32 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks