Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4.3 Name your source code file Hw1_1.java . Write a program that prompts the user for the name of a Java source code file. The

4.3 Name your source code file Hw1_1.java . Write a program that prompts the user for the name of a Java source code

file. The program shall read the source code file and output the contents to a new file named the same as the input

file, but with a .txt file name extension (e.g., if the input file is foo.java then the output file shall be named

foo.java.txt). Each line of the input file shall be numbered with a line number (formatted as shown below) in the

output file. For example, if the user enters Hw1_1.java as the name of the input file and Hw1_1.java contains:

//***************************************************************

// CLASS: Hw1_1 (Hw1_1.java)

//***************************************************************

public class Hw1_1 {

public static void main(String[] pArgs) {

}

public Hw1_1() {

}

}

then the contents of the output file Hw1_1.java.txt would be:

[001] //***************************************************************

[002] // CLASS: Hw1_1 (Hw1_1.java)

[003] //***************************************************************

[004] public class Hw1_1 {

[005] public static void main(String[] pArgs) {

[006] }

[007] public Hw1_1() {

[008] }

[009] }

Hint: to print an integer as shown above in a field of width 3 with leading 0's use the printf() method with a format

specifier of %03d.

}

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

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago