write a program that asks the user for the names of two files. the first file sh
ID: 3532483 • Letter: W
Question
write a program that asks the user for the names of two files. the first file should be opened for reading and the second file should be opened for writing . the program should read the contents of the first file, change all characters to uppercase, and store the results in the second file. the second file will be a copy of the first file, except that all the characters will be uppercase. use notepad or another text editor to create a simple file that can be used to test the program. Detailed explanation: NO Specific requirements: we are suppose to use the following on the assingmentFrankie owned a
ferocious feline named
Freddy as a pet.
Freddy was funny and
furry.
His fur is bright red
with black stripes. write a program that asks the user for the names of two files. the first file should be opened for reading and the second file should be opened for writing . the program should read the contents of the first file, change all characters to uppercase, and store the results in the second file. the second file will be a copy of the first file, except that all the characters will be uppercase. use notepad or another text editor to create a simple file that can be used to test the program. we are suppose to use the following on the assingment
Frankie owned a
ferocious feline named
Freddy as a pet.
Freddy was funny and
furry.
His fur is bright red
with black stripes. write a program that asks the user for the names of two files. the first file should be opened for reading and the second file should be opened for writing . the program should read the contents of the first file, change all characters to uppercase, and store the results in the second file. the second file will be a copy of the first file, except that all the characters will be uppercase. use notepad or another text editor to create a simple file that can be used to test the program. Detailed explanation: NO Specific requirements: we are suppose to use the following on the assingment
Frankie owned a
ferocious feline named
Freddy as a pet.
Freddy was funny and
furry.
His fur is bright red
with black stripes.
Explanation / Answer
import java.util.Scanner; // Needed for the Scanner class import java.io.*; // Needed for file classes public class Uppercase2 { public static void main(String[] args) throws IOException { String filename; String filename2; String writing; // Create a Scanner object for keyboard input. Scanner keyboard = new Scanner(System.in); // Get the first filename. System.out.print("Enter the first filename: "); filename = keyboard.nextLine(); // get the second filname System.out.print("Enter the second filename: "); filename2 = keyboard.nextLine(); // Open the reading file. FileReader freader = new FileReader(filename); BufferedReader inputFile = new BufferedReader(freader); // open output file FileWriter fwriter = new FileWriter(filename2); PrintWriter outputFile = new PrintWriter(fwriter); //writing = inputFile.readLine(); while ((writing = inputFile.readLine()) != null) { System.out.println(writing); // writing = inputFile.readLine(); String upper = writing.toUpperCase(); System.out.println(upper); outputFile.println(upper); } // close IO streams outputFile.close(); inputFile.close(); } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.