Code Image:
Sample Output:
Code to copy:
<!DOCTYPE html>
<html>
<head>
<!-- title-->
<title>Random Sentence Creator</title>
<!-- call java script-->
<script type = "text/javascript">
//Declare article as array assign those words to article
var article = ["the", "a", "one", "some", "any"];
//Declare noun as array assign those words to noun
var noun = ["boy", "girl", "dog", "town", "car"];
//Declare verb as array assign those words to verb
var verb = ["drove", "jumped", "ran", "walked", "skipped"];
//Declare preposition as array assign those words to preposition
var preposition = ["to", "from", "over", "under", "on"];
//Implementation of loadPage function
function loadPage()
{
var shortStoryline = "Once upon a time. ..\n";
//Declare number as type of var
var number = 20;
//Iterate the loop
for (var k = 1; k <= number; k++)
//create shortStoryline
shortStoryline = shortStoryline + generateRandomSentence();
//add shortStoryline
shortStoryline = shortStoryline + "\nTHE END.";
//shortStorylineField.value
document.getElementById("shortStorylineField").value = shortStoryline;
}
// Implementation of generateRandomSentence function
function generateRandomSentence()
{
//Declare sentence as type of var
var sentence = capitalWord(randomWordGen(article)) + " " + randomWordGen(noun)
+ " " + randomWordGen(verb) + " " + randomWordGen(preposition)
+ " " + randomWordGen(article) + " " + randomWordGen(noun) + ". ";
return sentence;
}
// Implementation of capitalWord function
function capitalWord(firstwordofsentence)
{
//get the capital letter
var capitalLetter = firstwordofsentence.charAt(0);
//convert into capitalLetter
capitalLetter = capitalLetter.toUpperCase();
//get the sub string
var sub = firstwordofsentence.substr(1);
//calculate firstwordofsentence
firstwordofsentence = capitalLetter + sub;
return firstwordofsentence;
}
// Implementation of randomWordGen function
function randomWordGen(result)
{
//Declare randValue as type of var
var randValue = Math.random() * result.length;
//Declare resultIndex as type of var
var resultIndex = Math.floor(randValue);
return result[ resultIndex ];
}
</script>
</head>
<body onload = "loadPage()">
<form action = "">
<!-- paragraph-->
<p><textarea id = "shortStorylineField" cols = "100" rows = "8"></textarea></p>
</form>
</body
</html>
Write a script that uses random number generation to create sentences. Use four arrays of strings...
Write a program that uses the random number generator to create sentences. The program should use four arrays of pointers to char called article, noun, verb and preposition. The sentences are constructed in the following order: article, noun, verb, preposition, article, noun. The program should generate 20 sentences. Capitalize the first letter. The arrays should contain: article "the", "one", "a", "some", "any" noun "boy", "girl", "dog", "town", "car" verb "drove", "jumped", "walked", "ran", "skipped" preposition "to", "from", "over", "under", "on"...
Assignment #6 - Arrays and Strings - Making random sentences! Due: Tuesday April 2, 11:59:00 pm Objective This assignment will consist of writing a program that involves practice with arrays, random number generation, and Strings. You may use c-strings or string objects here, however, string objects is recommended. Exercise Filename: sentences.cpp Write a program that uses random-number generation to create sentences. Create four arrays of strings (string objects highly suggested over c-strings) called article, noun, verb, and preposition. The arrays...
Can somebody help me with Java programming? please be brief and explain the process and carefully follow the step by step instruction. Thanks Homework 12.1 - Write a program that generates five random sentences (like mad libs), prints them to a file, then reads in the sentences and prints them to the console. Start by creating four string arrays for nouns, verbs, colors, and places. They should store at least 5 of each type of word. You can have more...
For this assignment, you will use your knowledge of arrays and ArrayLists to write a Java program that will input a file of sentences and output a report showing the tokens and shingles (defined below) for each sentence. Templates are provided below for implementing the program as two separate files: a test driver class containing the main() method, and a sentence utilities class that computes the tokens and shingles, and reports their values. The test driver template already implements accepting...
Hi there! I need to compare two essay into 1 essay, and make it interesting and choose couple topics which im going to talk about in my essay FIRST ESSAY “Teaching New Worlds/New Words” bell hooks Like desire, language disrupts, refuses to be contained within boundaries. It speaks itself against our will, in words and thoughts that intrude, even violate the most private spaces of mind and body. It was in my first year of college that I read Adrienne...