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 4 of 4

Thread: Assignment Help.

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

    Post Assignment Help.

    So, here the question !

    Write a Java code of the method startsWithCount that takes an array of strings words and a String S. The method should return an integer that is the number of strings that starts with S.

    For example if:
    words = { "All", "Arab", "size", "Almond", "Allowed", "here"} and S= "All", then the method should return 2

    This is what I have tried - This is the following answer right. Need help?

    PHP Code:
    public class StringwithCount {
    public static 
    void main (String[]args) {
    String strings[] = { "All""Arab""size""Almond""Allowed""here"};
    String output"";

    for ( 
    int i  =  0;  words.lengthi++) { 
                if (
    words[i].startsWith("s")) 
                    
    + +; 
            } 


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,349
    Thanks
    49
    Thanked 2,203 Times in 2,176 Posts

    Default Re: Assignment Help.

    can you explain what problems you are having?

    The assignment says to define a method. You should start with the definition for the header of the method.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Apr 2014
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Assignment Help.

    I just need to know weather my answer is right according to the Question.
    Header?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,349
    Thanks
    49
    Thanked 2,203 Times in 2,176 Posts

    Default Re: Assignment Help.

    The posted code doesn't compile so it wouldn't be a correct answer.

    When the code compiles, executes and prints out the right answer, then it might be ok.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Behaviour of shortcut assignment and normal assignment for float
    By rakeshkr2 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 20th, 2014, 02:54 AM
  2. Assignment
    By sabeeh in forum Java Applets
    Replies: 19
    Last Post: January 22nd, 2013, 10:14 AM
  3. Assignment help
    By hws in forum Java Theory & Questions
    Replies: 1
    Last Post: December 30th, 2011, 11:14 AM
  4. assignment troubles polymorphism (guide for assignment included)
    By tdawg422 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 8th, 2011, 10:01 AM
  5. Replies: 1
    Last Post: February 22nd, 2010, 07:20 AM