Answer & Explanation:Write a short Java application that stores words in an Array or ArrayList. You get to pick the number of words to store. Generate a random number between 0 (inclusive) and the length of the Array or ArrayList (exclusive). Use this random number as an index into the Array or ArrayList. Display the value stored at the index. Take a screenshot to verify that the words in your Array or ArrayList are displayed successfully. Cut and paste the screenshot into a Word document and attach this document to your submission. Here is my code below but I’m not sure how to generate an index number. Also, is my code done correctly. Please advise.WordTE.txt
wordte.txt
wordte.txt
wordte.txt
wordte.txt
Unformatted Attachment Preview
package wordup;
/**
*
* @author philip.johnson1
*/
public class WordUp
{
public static void main(String[] args)
{
System.out.println ( “Display my words list.”);
for ( int i = 0; i < 4; i ++ )
{
System.out.println ( Sentence () );
}
}
public static String Sentence ()
{
int value = 0;
String msg = "";
String [] subject = { "beast", "lion", "lamb" };
String [] adverb = { "slowly", "develop", "speed"
String [] verb = { "shifts", "adapts", "hibernate"
};
};
String [] adjective = { "jumps", "runs", "hides in" };
String [] object = { "boat", "village", "land" };
String vowels = "aeiouAEIOU";
value = ( int ) ( Math.random () * 3 );
//check if names starts with a vowel
if( vowels.contains ( "" + subject [ value ].charAt ( 0 ) ) )
{ msg = 1 + "." + "An " + subject [ value ]; }
else
{ msg = "A " + subject [ value ]; }
//The math.random function will roll the dice 3 times.
value = ( int ) ( Math.random () * 3 );
msg = msg + " " + adverb [ value ];
//The math.random function will roll the dice 3 times.
value = ( int ) ( Math.random () * 3 );
msg = msg + " " + verb [ value ];
//The math.random function will roll the dice 3 times.
value = ( int ) ( Math.random () * 3 );
msg = msg + " " + adjective [ value ];
//The math.random function will roll the dice 3 times.
value = ( int ) ( Math.random () * 3 );
if ( vowels.contains ( "" + object [ value ].charAt ( 0 ) ) )
{ msg = msg + " an " + object [ value ] + "."; }
else
{ msg = msg + " a " + object [ value ] + ".";
return msg;
}
}
}
package wordup;
/**
*
* @author philip.johnson1
*/
public class WordUp
{
public static void main(String[] args)
{
System.out.println ( "Display my words list.");
for ( int i = 0; i < 4; i ++ )
{
System.out.println ( Sentence () );
}
}
public static String Sentence ()
{
int value = 0;
String msg = "";
String [] subject = { "beast", "lion", "lamb" };
String [] adverb = { "slowly", "develop", "speed"
String [] verb = { "shifts", "adapts", "hibernate"
};
};
String [] adjective = { "jumps", "runs", "hides in" };
String [] object = { "boat", "village", "land" };
String vowels = "aeiouAEIOU";
value = ( int ) ( Math.random () * 3 );
//check if names starts with a vowel
if( vowels.contains ( "" + subject [ value ].charAt ( 0 ) ) )
{ msg = 1 + "." + "An " + subject [ value ]; }
else
{ msg = "A " + subject [ value ]; }
//The math.random function will roll the dice 3 times.
value = ( int ) ( Math.random () * 3 );
msg = msg + " " + adverb [ value ];
//The math.random function will roll the dice 3 times.
value = ( int ) ( Math.random () * 3 );
msg = msg + " " + verb [ value ];
//The math.random function will roll the dice 3 times.
value = ( int ) ( Math.random () * 3 );
msg = msg + " " + adjective [ value ];
//The math.random function will roll the dice 3 times.
value = ( int ) ( Math.random () * 3 );
if ( vowels.contains ( "" + object [ value ].charAt ( 0 ) ) )
{ msg = msg + " an " + object [ value ] + "."; }
else
{ msg = msg + " a " + object [ value ] + ".";
return msg;
}
}
}
package wordup;
/**
*
* @author philip.johnson1
*/
public class WordUp
{
public static void main(String[] args)
{
System.out.println ( "Display my words list.");
for ( int i = 0; i < 4; i ++ )
{
System.out.println ( Sentence () );
}
}
public static String Sentence ()
{
int value = 0;
String msg = "";
String [] subject = { "beast", "lion", "lamb" };
String [] adverb = { "slowly", "develop", "speed"
String [] verb = { "shifts", "adapts", "hibernate"
};
};
String [] adjective = { "jumps", "runs", "hides in" };
String [] object = { "boat", "village", "land" };
String vowels = "aeiouAEIOU";
value = ( int ) ( Math.random () * 3 );
//check if names starts with a vowel
if( vowels.contains ( "" + subject [ value ].charAt ( 0 ) ) )
{ msg = 1 + "." + "An " + subject [ value ]; }
else
{ msg = "A " + subject [ value ]; }
//The math.random function will roll the dice 3 times.
value = ( int ) ( Math.random () * 3 );
msg = msg + " " + adverb [ value ];
//The math.random function will roll the dice 3 times.
value = ( int ) ( Math.random () * 3 );
msg = msg + " " + verb [ value ];
//The math.random function will roll the dice 3 times.
value = ( int ) ( Math.random () * 3 );
msg = msg + " " + adjective [ value ];
//The math.random function will roll the dice 3 times.
value = ( int ) ( Math.random () * 3 );
if ( vowels.contains ( "" + object [ value ].charAt ( 0 ) ) )
{ msg = msg + " an " + object [ value ] + "."; }
else
{ msg = msg + " a " + object [ value ] + ".";
return msg;
}
}
}
package wordup;
/**
*
* @author philip.johnson1
*/
public class WordUp
{
public static void main(String[] args)
{
System.out.println ( "Display my words list.");
for ( int i = 0; i < 4; i ++ )
{
System.out.println ( Sentence () );
}
}
public static String Sentence ()
{
int value = 0;
String msg = "";
String [] subject = { "beast", "lion", "lamb" };
String [] adverb = { "slowly", "develop", "speed"
String [] verb = { "shifts", "adapts", "hibernate"
};
};
String [] adjective = { "jumps", "runs", "hides in" };
String [] object = { "boat", "village", "land" };
String vowels = "aeiouAEIOU";
value = ( int ) ( Math.random () * 3 );
//check if names starts with a vowel
if( vowels.contains ( "" + subject [ value ].charAt ( 0 ) ) )
{ msg = 1 + "." + "An " + subject [ value ]; }
else
{ msg = "A " + subject [ value ]; }
//The math.random function will roll the dice 3 times.
value = ( int ) ( Math.random () * 3 );
msg = msg + " " + adverb [ value ];
//The math.random function will roll the dice 3 times.
value = ( int ) ( Math.random () * 3 );
msg = msg + " " + verb [ value ];
//The math.random function will roll the dice 3 times.
value = ( int ) ( Math.random () * 3 );
msg = msg + " " + adjective [ value ];
//The math.random function will roll the dice 3 times.
value = ( int ) ( Math.random () * 3 );
if ( vowels.contains ( "" + object [ value ].charAt ( 0 ) ) )
{ msg = msg + " an " + object [ value ] + "."; }
else
{ msg = msg + " a " + object [ value ] + ".";
return msg;
}
}
}
...
Purchase answer to see full
attachment
You will get a plagiarism-free paper and you can get an originality report upon request.
All the personal information is confidential and we have 100% safe payment methods. We also guarantee good grades
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more