Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project Description Implement a simple file reader using your programming language of choice. The user is queried for the filename of an input file assumed

Project Description

Implement a simple file reader using your programming language of choice. The user is queried for the filename of an input file assumed to be in the same directory as the executable reader. The reader reads a file containing a sequence of characters and outputs each character to the screen, including whitespaces, along with its line and character positions in index-one-based numbering. After reading and displaying the input file has been completed, the user is queried for a new filename to read, infinitely, until the user responds with quit or exit. Descriptive code comments and version control (i.e., Git) messages demonstrating progress within the completion of the project are required. You are not allowed to use any library or module that supports regular expressions in Java

Your program should include three procedures (each of which may be used in later projects): 1. nextChar(): reads the next character in the input file. (This will not return anything: it will cause the next character to be stored in memory.) 2. currentChar(): returns a string containing the character that was just read. 3. position(): returns a string containing the line and column integers separated by a colon character.

The main program should have a loop for reading the input and printing the characters as follows: nextChar(); while ( currentChar() != end-of-text ) { print ( position() + + currentChar() ); nextChar(); }

Every character from the text file should be outputted to its own line on the screen in the following format: currentLine() + : + currentColumn() + + currentChar()

For example, for an input file containing the following text: Hello COSC 333!

The reader should produce the following output: 1:1 H 1:2 e 1:3 l 1:4 l 1:5 o 2:0 2:1 C 2:2 O 2:3 S 2:4 C 2:5 2:6 3 2:7 3 2:8 3 2:9 !

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

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago