Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By jim829

Thread: Generating random sentences

  1. #1
    mayank1 is offline Member
    Join Date
    Nov 2014
    Posts
    3
    Rep Power
    0

    Default Generating random sentences

    I have been set this task, which is supposed to make me code using string arrays. The idea is to generate random sentences.
    This is what i have been able to do so far :
    package usingarraysagain;

    public class sentences {
    public static void main (String[] args){
    String[] NOUNS = { "lizards",
    "Nikola Tesla",
    "Michael Faraday",
    "James maxwell",
    "dogs",
    "Java"};

    String[] verbphrases = {"deciphered",
    "pained",
    "enlightened",
    "eviscerated",}; }

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Generating random sentences

    Do you have a question?

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    mayank1 is offline Member
    Join Date
    Nov 2014
    Posts
    3
    Rep Power
    0

    Default Re: Generating random sentences

    Sorry, yes. I understand that I have to randomly select the nouns and the verbs ( I think), but I don't know how to actually do it.

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Generating random sentences

    Quote Originally Posted by mayank1 View Post
    Sorry, yes. I understand that I have to randomly select the nouns and the verbs ( I think), but I don't know how to actually do it.
    Do you know how to index arrays and generate random numbers? Assuming this is for a class, these concepts should have been covered before assigning this type of task.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    mayank1 is offline Member
    Join Date
    Nov 2014
    Posts
    3
    Rep Power
    0

    Default Re: Generating random sentences

    Quote Originally Posted by jim829 View Post
    Do you know how to index arrays and generate random numbers? Assuming this is for a class, these concepts should have been covered before assigning this type of task.

    Regards,
    Jim
    Not really, no, although I'm aware it involves the nextint method

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Generating random sentences

    If you don't know how to use arrays then you should check out Arrays (The Java Tutorials > Learning the Java Language > Language Basics)

    Regards,
    Jim
    DarrylBurke likes this.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Generating random numbers.
    By Zarquad in forum New To Java
    Replies: 1
    Last Post: 07-25-2013, 11:31 PM
  2. generating random integers
    By javaFREEK in forum New To Java
    Replies: 7
    Last Post: 10-19-2012, 09:56 AM
  3. Generating random numbers
    By chinedum in forum New To Java
    Replies: 9
    Last Post: 09-21-2011, 05:03 AM
  4. Math.random generating 0
    By codeAJ in forum New To Java
    Replies: 1
    Last Post: 03-25-2011, 08:17 AM
  5. Creating random sentences
    By bluekswing in forum New To Java
    Replies: 4
    Last Post: 06-27-2007, 05:45 PM

Tags for this Thread

Posting Permissions

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