Question

ArraysAndFiles.java and PartiallyFilledArray.java. They are shells that do not do anything. You will be adding code...

ArraysAndFiles.java and PartiallyFilledArray.java. They are shells that do not do anything. You will be adding code after the comments in the main method and using the javadoc documentation to implement the other methods.

Task 1: Send array data to the screen

In ArraysAndFiles.java, create a new method printOnScreen and compile it.

In the main method of ArraysAndFiles.java, add the code to declare and initialize the array of Strings and call printOnScreen to print the array on the screen.

Task 2: Send array data to a textfile

In the main method of ArraysAndFiles.java

Add code to open a textfile named "Output.txt"

Write the array contents to the textfile using an "enhanced for" loop.

Task 3: Read data from a file into a completely-filled array

Create an input file: Using a text editor, create an input file called “Input.txt” with these subjects. Put one per line:

Computer Science

Mathematics

Biology

English

Physical Education

Read array data from a textfile into a completely-filled array

In the main method of ArraysAndFiles.java, open the input textfile named “Input.txt”.

Create an array of Strings. The size of the array must be the same as the number of Strings in the file.

Read new data from the textfile into the array.

Task 4: Work with a partially-filled array

In PartiallyFilledArray.java, create a new method printPartiallyFilledArray and compile it.

In the main method of PartiallyFilledArray.java

Instantiate a String array that can contain 10 strings.

Write a sentinel-controlled (“q” to quit) loop to read some strings into an array from the keyboard and count how many have been read in. Possibly, they will only partially fill it up.

Call the printPartiallyFilledArray method to print the array elements that were read in.

Your program will be graded according your adherence to the following specifications:

Program compiles and runs without errors.

Appropriate data types and descriptive names are chosen for all variables and constants.

The program is properly indented.

Submit ArraysAndFiles.java and PartiallyFilledArray.java for grading to the blackboard.

(Sample output of ArraysAndFiles.java)

First Shell

/**
 * ArraysAndFiles contains codes to read array items
 * from files and send array items to files.  
 *
 */
import java.io.*;

public class ArraysAndFiles
{
     public static void main(String[] args) throws IOException
    {
        // Declare and initialize an array of Strings.  This one
        // will contain "A", "B", "C", "D", "E", "F", "G"
        
        
        // Print the array contents on the screen
        
        
        // Open a textfile "Output.txt" 
        
                
        // Write the array contents to the textfile using an "enhanced for" loop.
         

        
        // Open an input textfile named "Input.txt".
        

        // Read new data into the array of names from "Input.txt" one String per line, and places them in an array. 
        //The number of Strings in the file must be the same as the number of cells in the array.
                
                
       
       
       // Print the new array contents on the screen
        
        
        
    }

    /**
     * Method printOnScreen sends the entire contents of an 
     * array to the Screen using an "enhanced for" loop.
     * 
     * param array the array of Strings be printed on Screen
     * 
     */
    
   
    
}
/**

Second Shell

/**
 * Class PartiallyFilledArray  reads items for a 
 * partially-filled array from the keyboard, and
 * then prints them on the screen.  
 */
public class PartiallyFilledArray
{

    public static void main(String [] args)
    {
        // Instantiate a String array that can contain 10 items.
        
       
        // Read names of subjects into this array
        // and count how many have been read in.
        // There may be fewer than 10.
        



        // Call printPartiallyFilledArray to print the names in the array.
       
    }


        /**
         * Method printPartiallyFilledArray prints the String values 
         * in a partially-filled array, one per line.  Only the 
         * significant items in the array should be printed.
         * 
         * param array the array of Strings to be printed on the screen
         * param count the number of items in the partially-filled array
         */
}
0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
ArraysAndFiles.java and PartiallyFilledArray.java. They are shells that do not do anything. You will be adding code...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Question 1[JAVA] Add a method in the Main class named getLines() that takes a filename as...

    Question 1[JAVA] Add a method in the Main class named getLines() that takes a filename as a String and returns each line in the file in an array. Have each element of the array be a String. Do not include the newline at the end of each line. Use a BufferedReader object to read the file contents. Note, the contents of input.txt will be different (including the number of lines) for each test case. Example: getLines( "input.txt" ) returns (an...

  • create a new Java application called "CheckString" (without the quotation marks) according to the following guidelines....

    create a new Java application called "CheckString" (without the quotation marks) according to the following guidelines. ** Each method below, including main, should handle (catch) any Exceptions that are thrown. ** ** If an Exception is thrown and caught, print the Exception's message to the command line. ** Write a complete Java method called checkWord that takes a String parameter called word, returns nothing, and is declared to throw an Exception of type Exception. In the method, check if the...

  • Task #3 Arrays of Objects 1. Copy the files Song java (see Code Listing 7.1), Compact...

    Task #3 Arrays of Objects 1. Copy the files Song java (see Code Listing 7.1), Compact Disc.java (see Code Listing 7.2) and Classics.txt (see Code Listing 7.3) from the Student Files or as directed by your instructor. Song.java is complete and will not be edited. Classics.txt is the data file that will be used by Compact Disc.java, the file you will be editing. 2. In Compact Disc.java, there are comments indicating where the missing code is to be placed. Declare...

  • In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program...

    In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program to create a database of dogs of your own. You will also include File I/O with this program. You will create 3 classes for this assignment. The first class: Create a Class representing the information that is associated with one item (one dog) of your database. Name this class Dog. Using Lab 3, this will include the information in regard to one dog. The...

  • Set-Up · Create a new project in your Eclipse workspace named: Lab13 · In the src...

    Set-Up · Create a new project in your Eclipse workspace named: Lab13 · In the src folder, create a package named: edu.ilstu · Import the following files from T:\it168\Labs\lab13. Note that the .txt file must be in the top level of your project, not inside your src folder. o Student.java o StudentList.java o students.txt Carefully examine the Student.java and StudentList.java files. You are going to complete the StudentList class (updating all necessary Javadoc comments), following the instruction in the code....

  • I've been assigned to create a new Java application called "CheckString" (without the quotation marks) according...

    I've been assigned to create a new Java application called "CheckString" (without the quotation marks) according to the following guidelines. ** Each method below, including main, should handle (catch) any Exceptions that are thrown. ** ** If an Exception is thrown and caught, print the Exception's message to the command line. ** Write a complete Java method called checkWord that takes a String parameter called word, returns nothing, and is declared to throw an Exception of type Exception. In the...

  • create case 4 do Method 1:copy item by item and skip the item you want to...

    create case 4 do Method 1:copy item by item and skip the item you want to delete after you are done, delete the old file and rename the new one to the old name. #include int main(void) { int counter; int choice; FILE *fp; char item[100]; while(1) { printf("Welcome to my shopping list\n\n"); printf("Main Menu:\n"); printf("1. Add to list\n"); printf("2. Print List\n"); printf("3. Delete List\n"); printf("4. Remove an item from the List\n"); printf("5. Exit\n\n"); scanf("%i", &choice); switch(choice) { case 1:...

  • Lab Objectives Be able to write methods Be able to call methods Be able to declare...

    Lab Objectives Be able to write methods Be able to call methods Be able to declare arrays Be able to fill an array using a loop Be able to access and process data in an array Introduction Methods are commonly used to break a problem down into small manageable pieces. A large task can be broken down into smaller tasks (methods) that contain the details of how to complete that small task. The larger problem is then solved by implementing...

  • Write you code in a class named HighScores, in file named HighScores.java. Write a program that...

    Write you code in a class named HighScores, in file named HighScores.java. Write a program that records high-score data for a fictitious game. The program will ask the user to enter five names, and five scores. It will store the data in memory, and print it back out sorted by score. The output from your program should look approximately like this: Enter the name for score #1: Suzy Enter the score for score #1: 600 Enter the name for score...

  • Array lists are objects that, like arrays, provide you the ability to store items sequentially and...

    Array lists are objects that, like arrays, provide you the ability to store items sequentially and recall items by index. Working with array lists involves invoking ArrayList methods, so we will need to develop some basic skills. Let's start with the code below: The main method imports java.utii.ArrayList and creates an ArrayList that can hold strings by using the new command along with the ArrayList default constructor. It also prints out the ArrayList and, when it does, we see that...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT