EBK BUILDING JAVA PROGRAMS
EBK BUILDING JAVA PROGRAMS
4th Edition
ISBN: 9780134323718
Author: Stepp
Publisher: PEARSON CUSTOM PUB.(CONSIGNMENT)
bartleby

Concept explainers

bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 7, Problem 18E

Explanation of Solution

Method “wordLengths()” to print the “*” for the words containing each number of letters.

//Import required packages

import java.io.File;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.util.Scanner;

//Definition of class Test

public class Test

{

    //Definition of main class

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

    {

        //Open the file

Scanner input=new Scanner(new FileReader("input.txt"));

        //Call the method transpose

        wordLengths(input);

    }

    //Definition of method wordLengths

    public static void wordLengths(Scanner infile)

            throws FileNotFoundException

    {

        //Create an array

        int[] arr = new int[100];

        int size = 0;

        String tok;

//While loop to retrieve the words from the file

        while(infile.hasNext())

        {

            //Store the words in the variable "tok"

            tok = infile.next();

            //Increment the array size

            arr[tok.length()]++;

//Check whether the length is greater than size

            if(tok.length() > size)

                //Assign length to the size

                size = tok...

Blurred answer
Students have asked these similar questions
You were requested to design IP addresses for the following network using the address block 10.10.10.0/24. Specify an address and net mask for each network and router interface
For the following network, propose routing tables in each of the routers R1 to R5
For the following network, propose routing tables in each of the routers R1 to R5

Chapter 7 Solutions

EBK BUILDING JAVA PROGRAMS

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
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
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