Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*****ADD COMMENTS FOR THE FOLLOWING CODE PLEASE***** ********I ADD A COUPLES OF COMMENTS JUST TO BE CLEAR FOR YOU****** import java.util.Scanner; public class A5 {

*****ADD COMMENTS FOR THE FOLLOWING CODE PLEASE*****

********I ADD A COUPLES OF COMMENTS JUST TO BE CLEAR FOR YOU******

import java.util.Scanner; public class A5 { public static double averageStudentWordLength(String[] sentence) { int theWordSum = 0; //for will scan (sentence) for (int i = 0; i

public static double[] averageAllStudentWordLength(String[][] allStudentsSentence) { double[] eachAvrStudent = new double[allStudentsSentence.length]; //element must check the array step by step,each sentence in order for (int i = 0; i maximum) maximum = averagetWordLengths[i]; } return maximum; }

public static void main(String args[]) { Scanner input = new Scanner(System.in); int numbrOfStudents; System.out.print("Enter number of students in the class: "); numbrOfStudents = input.nextInt(); String words[] = new String[20]; String word; int wordsIndex ; String name; String[] names = new String[numbrOfStudents]; String[][] sentences = new String[numbrOfStudents][];

for (int i = 0; i

System.out.println(">>>>>>>>>>>>>>>>>>>"); System.out.printf("The class has %d students and here are their sentences:%n",numbrOfStudents); double[] averageForAllStudent = averageAllStudentWordLength(sentences); String maxW = ""; double maxWordLength = maxAverageWordLength(averageForAllStudent); for (int i = 0; i

} }

THE OUTPUT

image text in transcribed

Das Sample Run: run: Enter number of students in the class: 10 Enter student 1 name and then his sentence (end with STOP): Ahmed Three can keep a secret, if two of them are dead. STOP Enter student 2 name and then his sentence (end with STOP) : Ashraqat Genius is one percent inspiration and ninety-nine percent perspiration. STOP Enter student 3 name and then his sentence (end with STOP) : Jana All that glitters is not gold. STOP Enter student 10 name and then his sentence (end with STOP): Badr I'm gonna make him an offer he can't refuse. STOP TM105/M105 THE-Final 6 of 7 2020-2021/Fall >>>> The class has 10 students and here are their sentences: Student 1 name: Ahmed, his average word length: 3.55, and his sentence is: Three can keep a secret, if two of them are dead. Student 2 name: Ashraqat, his average word length: 7.00, and his sentence is: Genius is one percent inspiration and ninety-nine percent perspiration. Student 3 name: Jana, his average word length: 3.79, and his sentence is: All that glitters is not gold. Student 10 name: Badr, his average word length: 4.00, and his sentence is: I'm gonna make him an offer he can't refuse. Student Ashraqat got the maximum average word length: 7.00 BUILD SUCCESSFUL (total time: 3 minutes 11 seconds)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

Students also viewed these Databases questions

Question

=+ Are unions company-wide, regional, or national?

Answered: 1 week ago

Question

=+j Explain the litigation risks in international labor relations.

Answered: 1 week ago