subject

Design a class FileArray that has a static method named writeArray. The method should take two arguments: the name of a file and a reference to an int array. The file should be opened as a binary file, the contents of the array should be written to the file, and then the file should be closed. Write a second static method in the class FileArray named readArray. The method should take two arguments: the name of a file and a reference to an int array. The file should be opened, data should be read from the file and written into the array, and then the file should be closed. FileArrayDemoDemonstrate both methods in a class called FileArrayDemo with the main method. Import both java. io.* and java. util.*;Creates a Scanner. Set a flag to false. while flag is falseUnder a try-catch-finally:Under try:Requests, and reads in the size of an int array called inputNumbers. It then creates the array and requests and reads in the values of the array. It also creates an output array of the same size called outputNumbers. Also request and read in the name of an output file of type .dat. It then creates the array and requests and reads in the values of the array. Call writeArray with references to the outputfile name and the array inputNumbers. Call readArray with references to the outputfile name and the array outputNumbers. Test for the various error conditions. Print out the output file. Set flag to trueUnder catch:Catch any InputMismatchException and print the trace (see output). – In this case set the flag to trueCatch and print the trace (see output).Catch and print the trace (see output).Catch any IOException and print the trace (see output).Under finally:Print "Program Completed"Sample Inputs/OutputsPlease enter the number of integers to enter:8.2InputMismatchjava. util. InputMismatchException at java. base/java. util. Scanner. throwFor(Scanner. java:939) at java. base/java. util. Scanner. next(Scanner. java:1594) at java. base/java. util. Scanner. nextInt(Scanner. java:2258) at java. base/java. util. Scanner. nextInt(Scanner. java:2212) at FileArrayDemo. main(FileArrayDemo. java:21)Program Loop CompletedPlease enter the number of integers to enter:-8.lang.: -8 at FileArrayDemo. main(FileArrayDemo. java:22)Program Loop CompletedPlease enter the number of integers to enter:4Please enter the name of the .dat file you want to write to and then read from;xxx. datPlease enter 4 integers:9 -9 12 54The numbers read from the file are:9 -9 12 54Program Loop Completed

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 01:50, divine134
A.) generate scaffolding to create database for your application. develop all the entities identified in assignment #2. add any additional that may be identified later. b.) add data validation rules to the models that are appropriate for your application and data. c.) create links for each scaffold in the header section. part 2: application updates [30 points] a.) add two additional views to the "home" controller you created in assignment #1. b.) the two views should be named as “privacy" and "". c.) link the two newly created views in the footer section. hint: you would need to modify the “home" controller definition and create “privacy. html. erb" and “.html. erb" files in appropriate locations.
Answers: 3
image
Computers and Technology, 22.06.2019 13:00, mariahrpoulin9630
Which part of the cpu accepts data?
Answers: 1
image
Computers and Technology, 22.06.2019 17:00, bnvghnbbb
Match the following. 1. show grouping of word processing tasks that can be performed quick access toolbar 2. shortcut location for commonly used elements scroll bars 3. organized commands used to modify documents ribbon 4. used to align and measure content in a word screen zoom bar 5. vertical and horizontal bars that are used to navigate through a document contextual tabs 6. displays the name of the document in use ruler 7. allows users to enlarge or shrink a visual of a word document title bar
Answers: 2
image
Computers and Technology, 22.06.2019 20:00, Jana1517
What is the worst-case complexity of the maxrepeats function? assume that the longest string in the names array is at most 25 characters wide (i. e., string comparison can be treated as o( class namecounter { private: int* counts; int nc; string* names; int nn; public: namecounter (int ncounts, int nnames); int maxrepeats() const; }; int namecounter: : maxrepeats () { int maxcount = 0; for (int i = 0; i < nc; ++i) { int count = 1; for (int j = i+1; j < nc; ++j) { if (names[i] == names[j]) ++count; } maxcount = max(count, maxcount); } return maxcount; }
Answers: 3
You know the right answer?
Design a class FileArray that has a static method named writeArray. The method should take two argum...

Questions in other subjects:

Konu
World Languages, 16.07.2020 05:01