Question
For each of the following questions, write a Java program to perform the task requested. Upload your java files (one .java file per question) FOR
For each of the following questions, write a Java program to perform the task requested. Upload your java files (one .java file per question) FOR NETBEANS not terminal. Also show where it connects the software to the computer. Like for example for me:
("\\Users\\monze_was_here\\Downloads\ ums.txt");
Important: Don't take a snapshot of your code and. Only .java file will be accepted because we need to download your code and test it.
Question 1:
Create a text file in notepad, type in or copy/paste any ten lines in the file and save it (contents and name of the file don't matter). Write a Java program that will ask the user to enter the file name created previously, the program will then display only the first five lines of the files content. Your program MUST use a loop to complete the file reading process.
Question 2:
Write a Java program that asks the user to enter two file names. The first file is the same one you created in Question 1 and should be opened for reading. The second file should be opened for writing. The program will read the contents of the first file, change the characters of the odd line numbers to uppercase, and store the results in the second files.
Notes:
The second file will be a copy of the first file, except that all the characters of the odd-numbered lines will be uppercase.
The String class in Java has a methode named toUpperCase(), you can use it to convert lower case to upper case strings.
Question 3:
Write a program that will write 5000 random integers in the range 0-1000 to a file named RandomNumbers.txt. Then, the program will read this file and do the following:
Write the even number to a new file named EvenNumbers.txt
Write the odd number to a new file named OddNumbers.txt
Write the following statistics to a new file named Stats.txt
Number of even values
Number of odd values
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started