Results 1 to 2 of 2
  1. #1
    hokieman07 is offline Member
    Join Date
    Apr 2008
    Posts
    1
    Rep Power
    0

    Default 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?

  2. #2
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    8

    Default

    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

  1. Hwlp with "Open", "Save", "Save as..."
    By trill in forum New To Java
    Replies: 3
    Last Post: 11-02-2010, 10:26 AM
  2. Replies: 1
    Last Post: 03-14-2008, 03:51 PM
  3. Replies: 1
    Last Post: 07-27-2007, 11:59 PM
  4. Replies: 1
    Last Post: 07-25-2007, 11:55 PM
  5. Replies: 1
    Last Post: 07-16-2007, 07:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •