Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: array+functions

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default array+functions

    could you help me to solve it Q; Write a function printStarts(int n). Write a loop from 1 to n and print stars in single line.

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: array+functions

    What have you tried? Where are you stuck?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: array+functions

    Welcome to the forum! Please read this topic to learn how to post code correctly and other useful info for new members.

  4. #4
    Junior Member
    Join Date
    May 2014
    Location
    manila, philippines
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: array+functions

    here's the algorithm+pseudocode that might help you solve this (am just saying, "instruction in plain english")

    1) write name of function (must accept an integer as parameter)
    2) start a loop using "for"
    3) from 1 to "whatever the integer parameter"...loop.... until current count is equal to "whatever the integer parameter"....increment count as you go
    4) for every loop....print a star

    here's the code.

     
    public void printStars(int numberOfStarsToPrint){
     
    //you might want to validate the parameter here (optional for you)
     
    // GB: solution removed
     
    }
     
    }

  5. #5
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: array+functions

    @johnbee: please review The Problem with Spoon-feeding.

  6. The Following User Says Thank You to GregBrannon For This Useful Post:

    JosAH (March 1st, 2019)

  7. #6
    Junior Member
    Join Date
    May 2014
    Location
    manila, philippines
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: array+functions

    sorry and thank you.

  8. #7
    Member
    Join Date
    Dec 2013
    Location
    Honolulu
    Posts
    83
    Thanks
    1
    Thanked 4 Times in 2 Posts

    Default Re: array+functions

    With the printers they have now or the older versions, I think that an empty class method would do it. Printing it out. In a single line; an if ..then statement is enclosed in a while loop. Use of a System.out.println method. Increment or decrement each counter or variable loop iteration. It comes out like this. 10 9 8 7 6 5 3 2 1

  9. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: array+functions

    Further posting on old threads may result in banning.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] Deprecated functions
    By dicdic in forum Java Theory & Questions
    Replies: 3
    Last Post: December 15th, 2013, 08:11 PM
  2. Using functions in a calculator
    By aesguitar in forum Java Theory & Questions
    Replies: 9
    Last Post: November 17th, 2013, 10:54 AM
  3. How this GUI functions
    By mathobject in forum Java Programming Tutorials
    Replies: 3
    Last Post: October 15th, 2012, 08:10 AM
  4. Hash Functions
    By Blueshark in forum Java Theory & Questions
    Replies: 3
    Last Post: July 2nd, 2012, 03:04 PM
  5. need help with using trig functions
    By Tdogg in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 1st, 2012, 06:47 AM