Note:- Study this program and follow the given instruction and type execute the code and also give output for this java program as soon as possible. INSTRUCTIONS:-  Modify example four to read integer values from the keyboard, store them into a 15 element array, then write the array into a file named userin.txt Write a program to create two files with the names file4.txt and file4a.txt     two 10 element int arrays with the names arrfile4 and arrfile4a; these arrays are to have different values     write the contents of arrfile4 to file4.txt     write the contents of arrfile4a to file4a.txt exampleFour In the while loop, this program reads fileLoop.txt until all items are read; Each item in the file is stored into an array   package storeintoarr;   import java.util.Scanner; import java.io.*;   public class Storeintoarr {           public static void main(String[] args) throws IOException     {        File loopfile = new File("fileLoop.txt");              Scanner getAll = new Scanner( loopfile );          // connect a Scanner to the file     int num = 0, square = 0;     int[] items = new int[10];     int i = 0;     while(getAll.hasNextInt()){       num = getAll.nextInt();       square = num * num ;             //System.out.println("The square of " + num + " is " + square);       items[i] = num;       System.out.println("items[i] is " + items[i]);       i = i + 1;     }     getAll.close();     }

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section8.3: Random File Access
Problem 6E
icon
Related questions
Topic Video
Question

Note:- Study this program and follow the given instruction and type execute the code and also give output for this java program as soon as possible.

INSTRUCTIONS:- 

  • Modify example four to read integer values from the keyboard, store them into a 15 element array, then write the array into a file named userin.txt
  • Write a program to create two files with the names file4.txt and file4a.txt
  •     two 10 element int arrays with the names arrfile4 and arrfile4a; these arrays are to have different values
  •     write the contents of arrfile4 to file4.txt

        write the contents of arrfile4a to file4a.txt

exampleFour

In the while loop, this program reads fileLoop.txt until all items are read;

Each item in the file is stored into an array

 

package storeintoarr;

 

import java.util.Scanner;

import java.io.*;

 

public class Storeintoarr {

 

   

    public static void main(String[] args) throws IOException

    {

       File loopfile = new File("fileLoop.txt");  

      

    Scanner getAll = new Scanner( loopfile );    

     // connect a Scanner to the file

    int num = 0, square = 0;

    int[] items = new int[10];

    int i = 0;

    while(getAll.hasNextInt()){

      num = getAll.nextInt();

      square = num * num ;      

      //System.out.println("The square of " + num + " is " + square);

      items[i] = num;

      System.out.println("items[i] is " + items[i]);

      i = i + 1;

    }

    getAll.close();

    }

   

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning