Write an application program that uses random number generation to create sentences. Use four arrays of strings called article, noun, verb and proposition. Create a sentence by selecting a word at random from each array in the following order article noun, verb, proposition, article and noun. As each word is picked, concatenate it to the previous words in the sentence. The words should be separated by spaces. When a final sentence is output, it should start with a capital word and end with a period. The program should generate 20 sentences and output them one at a time.
The article array should contain "the","a","one","some", and "any"; the noun array should contain the nouns "boy", "girl", "dog", "town" and "car"; the verb array should contain the verbs "drove", "jumped","ran","walked", and "skipped"; the proposition array should contain the propositions "to", "from", "over", "under", and "on".
Create an HTML file that can be used to run your applet.
C(n,r) = n * (n-1) * (n-2) * ... * (n-r+1)/ (1* 2 * ... * r)
Your calculation should be done six times, using six different
variable types to store intermediate values: (1) as a
byte
; (2) as a short
; (3) as a
int
; (4) as a long
; (5) as a
java.lang.Integer
; and (6) as a
java.math.BigInteger
. In the comments of your code, explain
the differences between each of these data types, and how these
differences can affect the behavior of your program.
When you are writing code to perform this calculation, you should
use several different techniques and language constructs to perform
your computation. At a minimum, your code should demonstrate your
knowledge of the following: (1) the while
statement (JSS,
page 102); (2) the for
statement (JSS, page 196); and (3)
recursion (JSS, pages 443-461).
Student first_name : STRING; last_name : STRING; sex : STRING; Class : STRING;The corresponding Java Implementation is as follows:
public class Student { public String first_name,last_name,sex,Class; // Constructor public Student() { first_name="Joe";last_name="Bob";sex="Male"; Class="Freshman"; } public Student(String a, String b, String c, String d) { first_name=a;last_name=b;sex=c; Class=d; } public String FindClass() { return Class; } public void toPrint() { ... } }Assignment
Your assignment is to define a method toPrint in class Student in Java that prints the students first name, last name, sex and Class. generat
javadoc
tool to generate
the documentation, and you should include the documentation
with your homework submission.