HW10

.docx

School

Georgia Southern University *

*We aren’t endorsed by this school

Course

1301

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

3

Uploaded by BaronBoulderSeahorse44

Report
CSCI 1301 Homework #10 Due date: November 26, 2023 (Sunday), 11:59pm Text File Input and Output Write a method named createFile1 to create a file named hw10.txt. The method takes an int array as an input parameter and returns the file object associated with hw10.txt. If the file hw10.txt does not exist (if the file exists, let the method return null), write the all the numbers from the int array into the file using text I/O. Integers are separated by line breaks in the file. The array of 10 random integers ranging in [0, 99] is created in the main method to test this method. Please see the main method given in the next page. Please use the exact provided main method in your own program. In the same program, write another method called createFile2 to create a file named hw10_scale.txt. The method takes the returned file object by the createFile1 method as an input parameter and returns the file object associated with hw10_scale.txt. If the file does not exist (if the file exists, let the method return null), multiply all the numbers from hw10.txt by 10 and save all the new numbers in hw10_scale.txt. For example, if hw10.txt is 26 12 4 89 54 65 12 65 74 3 Then hw10_scale.txt should be: 260 120 40 890 540 650 120 650 740 30 Be sure that your source code compile and execute successfully.
Grading: This assignment is worth 100 points. Grade criteria Maximum points Correct result and output Proper implementation of all features specified in the program 80 Proper style and documentation * 20 * The requirement of proper style and documentation can be found in “Expanded Guidelines on Programming Style and Documentation” document in the “Course Info” module in folio. Please name your class file as “HW10”. For submission in Gradescope, please include the packages given below before you submit your code or your code won’t compile. package homework; import java.io.* ; import java.util.Scanner; public class HW10 { public static void main(String[] args ) throws IOException { int [] randomNumbers = new int [10]; for (int i = 0; i < randomNumbers .length; i++) { randomNumbers [i] = ( int ) (Math.random() * 100); } File file1 = generateFile1( randomNumbers ); if ( file1 == null) return ; File file2 = generateFile2(file1); if ( file2 == null) return ; } public static File createFile1( int [] numbers ) throws IOException { //Please write your code here } public static File createFile2( File file ) throws IOException { //Please write your code here } }
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help