Write a program to take an input file of normal english arti

 Write a program to take an input file of normal english article and generate a randomly shuffled output text file.   Take a look at this paragraph. Can you read what it says? All the letters have been jumbled (mixed). Only the first and last letter of ecah word is in the right place:  I cnduo\'t bvleiee taht I culod aulaclty uesdtannrd waht I was rdnaieg. Unisg the icndeblire pweor of the hmuan mnid, aocdcrnig to rseecrah at Cmabrigde Uinervtisy, it dseno\'t mttaer in waht oderr the lterets in a wrod are, the olny irpoamtnt tihng is taht the frsit and lsat ltteer be in the rhgit pclae. The rset can be a taotl mses and you can sitll raed it whoutit a pboerlm. Tihs is bucseae the huamn mnid deos not raed ervey ltteer by istlef, but the wrod as a wlohe. Aaznmig, huh? Yaeh and I awlyas tghhuot slelinpg was ipmorantt! See if yuor fdreins can raed tihs too.  Hide Paragraph  I couldn\'t believe that I could actually understand what I was reading. Using the incredible power of the human brain, according to research at Cambridge University, it doesn\'t matter in what order the letters in a word are, the only important thing is that the first and last letter be in the right place. The rest can be a total, mess and you can read it without a problem. This is because the human mind does not read every letter by itself, but the word as a whole. Amazing, huh? Yeah and I always thought spelling was important! See if your friends can read this too!  

Solution

program   package app;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
public class RandomWord
{
private String fileName = \"src/app/wordlist.txt\";
List<String> lines = null;
public static void main(String[] args)
{
RandomWord randomWord = new RandomWord();
randomWord.init();
}
private void init()
{
try
{
lines = Files.readAllLines(Paths.get(fileName),
StandardCharsets.UTF_8);
}
catch (IOException e)
{
System.out.println(\"File can\'t be opened.\");
}
int randomWordIndex = getRandomNumber(1, lines.size());
System.out.println(lines.get(randomWordIndex));
}
private int getRandomNumber(int min, int max)
{
return min + (int) (Math.random() * ((max - min) + 1));
}
}   
class RandomStringPicker
{
private final List<String> list;
public RandomStringPicker(List<String> list)
{
this.list = list;
}
public String pick()
{
return list.get(pickRandomNumber(list.size()));
}
private int pickRandomNumber(int max)
{
return (int) (Math.random() * max);
}
}
class RandomPicker<T>
{
private final List<T> list;
public RandomPicker(List<T> list)
{
this.list = list;
}
public T pick()
{
return list.get(pickRandomNumber(list.size()));
}
private int pickRandomNumber(int max)
{
return (int) (Math.random() * max);
}
}

 Write a program to take an input file of normal english article and generate a randomly shuffled output text file. Take a look at this paragraph. Can you read
 Write a program to take an input file of normal english article and generate a randomly shuffled output text file. Take a look at this paragraph. Can you read

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site