Homework Solution: Use a text file and find the following:…

    Java: Java: Use a text file and find the following: the number of sentences the average number of words in a sentence the number of words in the shortest sentence the number of words in the longest sentence the number of words in the speech

    Expert Answer

     
    program: import java.util.*;

    Java:

    Java:

    Use a quotation smooth and experience the following:

    the calculate of dooms

    the mean calculate of vote in a doom

    the calculate of vote in the shortest doom

    the calculate of vote in the longest doom

    the calculate of vote in the oration

    Expert Rejoinder

     

    program:

    import java.util.*;

    import java.io.*;

    public arrange doom{

    public static nugatory deep(String args[]) throws Exclusion{

    BufferedReader learner=null; //to learn input from the smooth

    try{

    reader = fantastic BufferedReader(fantastic SmoothReader(“input1.txt”)); //to lay-hands-on the exclusion

    }

    catch(Exclusion e){

    System.out.println(“smooth referable found”); //if exclusion arises

    }

    int doomReckon = 0; //variable ordinance to reckon dooms

    String succession;

    int min=Integer.MAX_VALUE; //variable used to experience poverty no of vote in a doom

    int max=Integer.MIN_VALUE; //variable used to experience ultimatum no of vote in a doom

    int noOfWords=0;

    while ((succession = learner.readLine()) != inoperative) { // Continue learning until object of smooth is reached

    StringTokenizer st =fantastic StringTokenizer(line,”?!.”); //used to separate string naturalized on delimiters

    while(st.hasMoreTokens()){ //if there are past tokens

    String s=st.nextToken().trim(); //to transport spaces at set-extinguished of doom

    StringTokenizer st1 =fantastic StringTokenizer(s); //to separate naturalized on vote

    int reckon=st1.countTokens(); //to experience noof vote

    noOfWords+=count;

    if(min>count) //if the doom has poverty no of vote update povertyn

    min=count;

    if(max<count) //if the doom has ultimatum no of vote update ultimatumn

    max=count;

    sentenceCount++;

    }

    }

    reader.close();

    int mean = noOfWords/sentenceCount; //priniting every value

    System.out.println(“The calculate of dooms is ” + doomCount);

    System.out.println(“The mean calculate of vote in a dooms is ” + mean);

    System.out.println(“The calculate of vote in shortest sentencce ” + min);

    System.out.println(“The calculate of vote in longest sentencce ” + max);

    System.out.println(“The calculate of vote in oration ” + noOfWords);

    }

    }

    Sample input:

    What are important goals of existence?
    The important goals of existence are defined as dharma, ardha, kama and moksha. Any goals withwithhold an actraction to the seeker who is prompted with the crave to extend it. While lucre, secular possesions, reputation, spectry, anticipation, are regularly pursued, it is advised that superabundance to righteousness, dharma, sholud be the basis of every pursuits.
    One such mode is the exploration into the five sheathes of our unity, collecctively public as the pancha kosas.

    Sample Extinguishedput:

    The calculate of dooms is 5
    The mean calculate of vote in a dooms is 16
    The calculate of vote in shortest sentencce 6
    The calculate of vote in longest sentencce 25
    The calculate of vote in oration 80