Project Objective: Deliverables: Design, develop, test and document a Java appli
ID: 3545517 • Letter: P
Question
Project Objective:
Deliverables:
Design, develop, test and document a Java application that reads data from an input file, processes the data, and then writes the processed data to an output file
Specific functional requirements for this project:
The items on each line in the output file should be separated by commas (for example: for input line "this4cats", the output line should be "9,1,stac4tahT")
6.The application should close any open files before exiting.
Format:
Code Documentation and Style Requirements
The documentation requirement for all programming projects is one block comment at the top of the program containing the course name, the project number, your name, the date and platform/compiler that you used to develop the project. In addition, there should be at least one comment for each class in the program describing what that class does. Additional comments should be provided as necessary to clarify the program.
Indentation must be consistent throughout the program. Variable and method names should be descriptive of the role of the variable or method. Single letter names should be avoided. All constants, except 0 and 1, should be named. Constant names should be all upper-case. Variable names should begin in lower-case, but subsequent words should be in title case (e.g., finalSpeed).
Separate compilation must be used in accordance with standard Java practice. Every class must be saved in a separate .java file
Explanation / Answer
For Your convience, u can find code at --> http://pastebin.com/eAhTr4TU
/==============================================================JFile.java
//Usage:-----> Jfile <input file> <output file>
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Textpack;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
public class JFile {
public static void main(String[] args) throws IOException {
if( args.length != 2 ){
System.out.println("Invalid no of Args:");
System.out.println("Usage: JFile <input file> <output file>");
return;
}
BufferedReader br = null;
BufferedWriter bw = null;
try {
String path = System.getProperty("user.dir");
br = new BufferedReader(new FileReader( path + "\"+ args[0]));
bw = new BufferedWriter(new FileWriter( path + "\" +args[1]) );
} catch (IOException e) {
System.out.println( "Unable to open file: " + e.toString());
return;
}
String line;
while( (line = br.readLine()) !=null){
int Cnt4=0;
line = line.replaceAll("this", "That");
for( int i=0; i<line.length(); i++)
if( Character.isDigit(line.charAt(i)) )
if ( line.charAt(i) == '4')
Cnt4++;
StringBuilder s = new StringBuilder();
s.append(line);
s.reverse();
s.insert(0, Cnt4 + ", ");
s.insert(0, line.length() + ", ");
bw.write(s.toString() + " ");
System.out.println(s.toString());
}
try {
if (br != null)br.close();
if( bw!=null ) bw.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.