Building Java Programs: A Back to Basics Approach (4th Edition)
Building Java Programs: A Back to Basics Approach (4th Edition)
4th Edition
ISBN: 9780134322766
Author: Stuart Reges, Marty Stepp
Publisher: PEARSON
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
I want to solve 13.2 using matlab please help
a) Show a possible trace of the OSPF algorithm for computing the routing table in Router 2 forthis network.b) Show the messages used by RIP to compute routing tables.
using r language to answer question 4 Question 4: Obtain a 95% standard normal bootstrap confidence interval, a 95% basic bootstrap confidence interval, and a percentile confidence interval for the ρb12 in Question 3.

Chapter 7 Solutions

Building Java Programs: A Back to Basics Approach (4th Edition)

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