Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2010
    Posts
    2
    Rep Power
    0

    Default Print Horizontal Bars

    Write a method, named printHorizontalBars(), that prompts the user for four values and draws corresponding bar graphs using an ASCII character. For example if the user entered 15, 12, 9 and 4, the program would draw.

    * * * * * * * * * * * * * * *
    * * * * * * * * * * * *
    * * * * * * * * *
    * * * *

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by xstrandedx7688 View Post
    Write a method, named printHorizontalBars(), that prompts the user for four values and draws corresponding bar graphs using an ASCII character. For example if the user entered 15, 12, 9 and 4, the program would draw.

    * * * * * * * * * * * * * * *
    * * * * * * * * * * * *
    * * * * * * * * *
    * * * *
    Most folks bristle when a poster simply posts their assignment without showing that they've done a lick of work, as if they expect others to do the assignment for them. Please show us that you've at least made a good faith attempt at solving this assignment by posting your attempt and then tell us what isn't working with your program.

    I look forward to seeing your reply. Best of luck.

  3. #3
    Join Date
    Mar 2010
    Posts
    2
    Rep Power
    0

    Default Hoping this is right!!!

    for (int row = 1; row <= 8; row++) {
    for (int col = 1; col <= 9 - row; col++) {
    System.out.print("#");
    }
    System.out.println();
    }

    Is this all there is to it?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by xstrandedx7688 View Post
    for (int row = 1; row <= 8; row++) {
    for (int col = 1; col <= 9 - row; col++) {
    System.out.print("#");
    }
    System.out.println();
    }

    Is this all there is to it?
    It's a start, but tell us: Does it compile? Does it work as required when you run it?

    You need to do all the things that the instructions tell you to do:

    1) create the method with the name given in the instructions.
    2) Prompt the user for 4 values and store them in 4 variables (I assume that you haven't worked with arrays yet, but please tell me if I'm wrong).
    3) Use those four values to print out your bars.

    A useful link to look at is the last one in my signature below.

    Keep working at it, cuz the more you exercise your mind, the easier this will be in the future. :)

    Best of luck!

Similar Threads

  1. Progress Bars - How do they work?
    By Unsub in forum New To Java
    Replies: 3
    Last Post: 02-26-2010, 06:56 AM
  2. cant get to print...
    By chango77745 in forum New To Java
    Replies: 0
    Last Post: 02-13-2009, 06:04 AM
  3. JFileChooser horizontal scrollbar problem
    By nenadm in forum AWT / Swing
    Replies: 4
    Last Post: 11-12-2008, 11:16 AM
  4. Replies: 0
    Last Post: 07-02-2008, 08:06 PM
  5. Print the text file and print preview them
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-22-2008, 11:04 PM

Posting Permissions

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