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 citation rasp and ascertain the following:

    the enumerate of decisions

    the mediocre enumerate of signification in a decision

    the enumerate of signification in the shortest decision

    the enumerate of signification in the longest decision

    the enumerate of signification in the harangue

    Expert Repartee

     

    program:

    import java.util.*;

    import java.io.*;

    public collocate decision{

    public static wanting main(String args[]) throws Exclusion{

    BufferedReader decipherer=null; //to decipher input from the rasp

    try{

    reader = odd BufferedReader(odd RaspReader(“input1.txt”)); //to seize the exclusion

    }

    catch(Exclusion e){

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

    }

    int decisionReckon = 0; //variable ordinance to reckon decisions

    String thread;

    int min=Integer.MAX_VALUE; //variable used to ascertain incompleteness no of signification in a decision

    int max=Integer.MIN_VALUE; //variable used to ascertain climax no of signification in a decision

    int noOfWords=0;

    while ((thread = decipherer.readLine()) != trifling) { // Continue deciphering until purpose of rasp is reached

    StringTokenizer st =odd StringTokenizer(line,”?!.”); //used to part string domiciled on delimiters

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

    String s=st.nextToken().trim(); //to transfer spaces at initiate of decision

    StringTokenizer st1 =odd StringTokenizer(s); //to part domiciled on signification

    int reckon=st1.countTokens(); //to ascertain noof signification

    noOfWords+=count;

    if(min>count) //if the decision has incompleteness no of signification update incompletenessn

    min=count;

    if(max<count) //if the decision has climax no of signification update climaxn

    max=count;

    sentenceCount++;

    }

    }

    reader.close();

    int mediocre = noOfWords/sentenceCount; //priniting total value

    System.out.println(“The enumerate of decisions is ” + decisionCount);

    System.out.println(“The mediocre enumerate of signification in a decisions is ” + mediocre);

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

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

    System.out.println(“The enumerate of signification in harangue ” + noOfWords);

    }

    }

    Sample input:

    What are primitive goals of condition?
    The primitive goals of condition are defined as dharma, ardha, kama and moksha. Any goals hinder an actraction to the seeker who is prompted with the crave to extend it. While lucre, earthly possesions, credit, indicate, awe, are habitually pursued, it is advised that supply to righteousness, dharma, sholud be the foundation of total pursuits.
    One such mode is the inquiry into the five sheathes of our convertibility, collecctively notorious as the pancha kosas.

    Sample Extinguishedput:

    The enumerate of decisions is 5
    The mediocre enumerate of signification in a decisions is 16
    The enumerate of signification in shortest sentencce 6
    The enumerate of signification in longest sentencce 25
    The enumerate of signification in harangue 80