Building Java Programs: A Back To Basics Approach (5th Edition)
Building Java Programs: A Back To Basics Approach (5th Edition)
5th Edition
ISBN: 9780135471944
Author: Stuart Reges, Marty Stepp
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 6, Problem 2PP

compareFiles Class

Program Plan Intro

Program plan:

  • Import the required header files.
  • Create the class “compareFiles”,
    • Define the “compareFiles ()” function.
      • Create the objects of scanner class “scanner1”and “scanner2”.
      • Create integer variable “lineNumber”.
      • Create string variable “line1”.
      • Create Boolean variable “different”.
      • Print the statement.
      • Iterate a “while” loop.
        • Get the lines from both the files to the variables “line1” and “line2”.
        • If the “line1” and “line2” are equal,
          • Print the value of “line2”.
        • Increment the value of “lineNumber” by 1.
      • If the condition “scanner1.hasNext()”is true,
        • Print the statement.
      • Else if the condition “scanner2.hasNext()” is true,
        • Print the statement.
      • Else if the condition “!different” is true,
        • Print the statement.
    • Define the “main ()” function.
      • Create an object of scanner class “scanner”.
      • Prompt the user to enter the name of first file.
      • Get the file name to string variable “filename1”.
      • Create the object named “file1” of “File” class.
      • Prompt the user to enter the name of second file.
      • Get the file name to string variable “filename2”.
      • Create the object named “file2” of “File” class.
      • Define a “try..catch” block.
        • Call the method “compareFiles()”.
      • Catch the exception “e”.
        • Print the exception “e”.

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 6 Solutions

Building Java Programs: A Back To Basics Approach (5th 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
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