BUILDING JAVA PROGRAMS-TEXT
BUILDING JAVA PROGRAMS-TEXT
5th Edition
ISBN: 2810023481209
Author: REGES
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 6, Problem 16E

Explanation of Solution

Program code:

commonNames.java

//import the required packages

import java.io.File;

import java.util.Arrays;

import java.util.Scanner;

//define a class commonNames

public class commonNames

{

    //define the main

    public static void main(String[] args) throws Exception

    {

//create the object of File class

File fileName = new File("file.txt");

//create the object of Scanner class to refer the file

Scanner input = new Scanner(fileName);

//call the method mostCommonNames()

mostCommonNames(input);

    }

//define the method mostCommonNames()

public static int mostCommonNames(Scanner input)

{

//declare an integer variable

int uniqueName=0;

//itrerate while loop to get the lines of the file

while(input.hasNextLine())

{

//create a string variable and get the lines to it

String line=input.nextLine();

//create the variable of Scanner

Scanner console=new Scanner (line);

//create a string and get the tokens to it

String last=console.next();

//increment the variable uniqueName by 1

uniqueName++;

//create a string variable and assign last to it

String commonWord=last;

//create two integer variables

int mostCommon=1;

int count=1;

//iterate a while loop to get the tokens

while(console.hasNext()

{

//create a string variable current and get the token to it

    String current=console.next();

//if the value of current and last are equal

    if(current.equals(last))

    {

        //increment the count by 1

        count++;

    }

//if the value of current and last are not equal

    else

    {

//if the count is greater than mostCommon

        if(count>mostCommon)

        {

//Assign the value of count to mostCommon

            mostCommon=count;

//Assign the value of last to mostCommon

            commonWord=last;

        }

        //set the value of count as 1

        count=1;

//increment the value of uniqueName by 1

        uniqueName++;

    }

    //assign the value of current to last

    last=current;

}

//if count is greater than mostCommon

if(count>mostCommon)

{

    //assign last to commonWord

    commonWord=last;

}

        //print the commonWord

System...

Blurred answer
Students have asked these similar questions
I cannot program smart home automation rules from my device using a computer or phone, and I would like to know how to properly connect devices such as switches and sensors together ? Cisco Packet Tracer 1. Smart Home Automation:o Connect a temperature sensor and a fan to a home gateway.o Configure the home gateway so that the fan is activated when the temperature exceedsa set threshold (e.g., 30°C).2. WiFi Network Configuration:o Set up a wireless LAN with a unique SSID.o Enable WPA2 encryption to secure the WiFi network.o Implement MAC address filtering to allow only specific clients to connect.3. WLC Configuration:o Deploy at least two wireless access points connected to a Wireless LAN Controller(WLC).o Configure the WLC to manage the APs, broadcast the configured SSID, and applyconsistent security settings across all APs.
using r language for integration theta = integral 0 to infinity (x^4)*e^(-x^2)/2 dx (1) use the density function of standard normal distribution N(0,1) f(x) = 1/sqrt(2pi) * e^(-x^2)/2 -infinity <x<infinity as importance function and obtain an estimate theta 1 for theta set m=100 for the estimate whatt is the estimate theta 1? (2)use the density function of gamma (r=5 λ=1/2)distribution f(x)=λ^r/Γ(r) x^(r-1)e^(-λx) x>=0 as importance function and obtain an estimate theta 2 for theta set m=1000 fir the estimate what is the estimate theta2? (3) use simulation (repeat 1000 times) to estimate the variance of the estimates theta1 and theta 2 which one has smaller variance?
using r language A continuous random variable X has density function f(x)=1/56(3x^2+4x^3+5x^4).0<=x<=2 (1) secify the density g of the random variable Y you find for the acceptance rejection method. (2) what is the value of c you choose to use for the acceptance rejection method (3) use the acceptance rejection method to generate a random sample of size 1000 from the distribution of X .graph the density histogram of the sample and compare it with the density function f(x)

Chapter 6 Solutions

BUILDING JAVA PROGRAMS-TEXT

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY