Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

File Input/Output Objective: Create a program that allows a user to fill in values for two separate arrays, then saves that information in a separate

File Input/Output

Objective: Create a program that allows a user to fill in values for two separate arrays, then saves that information in a separate file.

Related SLOs:

    SLO #1: Use an appropriate programming environment to design, code, compile, run, and debug computer programs.
    SLO #3: Illustrate basic programming concepts such as program flow and syntax of a high-level general-purpose language and basic security practices.
    SLO #4: Demonstrate working with primitive data types, strings, and arrays.

Instructions:

    Using jGRASP, write a Java program named LastnameFirstname09.java, using your last name and your first name, that does the following:
        Create two arrays that will hold related information. Allow the user to set the size of the arrays.
            Examples:
                an array that holds a person's name and an array that holds their phone number
                an array that holds a pet's name and an array that holds what type of animal that pet is
                an array that holds a student's name and an array that holds what their grade is.
        Allow the user to fill in the information for both arrays. Use one loop to do this.
        Define a method called saveFile. You will be able to pass your two arrays to this method. This method will save the contents of both arrays in a separate file so that the information in the different arrays are presented in a coherent manner.
            Examples:
                John's phone number is: 455-0123
                Ed's phone number is: 455-0987
                Blanca's phone number is: 455-3456
                Snoopy is a pet dog
                Garfield is a pet cat
                Pudge is a pet fish
                William : B
                Mike : C
                Pete : A
        Use one loop to write out the contents of the arrays.
        After your method saves the information, have the method print out a confirmation message that states where the information was saved. (see Example Output)
        Note: You can make your arrays hold whatever information you want. You don't need to follow the examples. Be creative as you wish! :)
        Yes, this is similar to a previous assignment. Yes, you can use your code from the previous assignment! :)
    Your program MUST:
        Actively use in-line comments stating what each section of code does.
        Use try/catch if, and only if, necessary.
        Begin storing data in the first box of the array - not the second.
    Your program must conform to the Java coding standards reviewed in class.
    Remember to always begin your code with the following documentation comments:

/**
 * Short description of the program.
 *
 * @author     Last Name, First Name
 * @assignment ICS 105 Assignment XX
 * @date       Today's Date
 * @bugs       Short description of bugs in the program, if any.
 */

Expected Output:

    This is an example of what your program should output:

 ----jGRASP exec: java DoeJohn09
Hello! This is a phonebook program!
This program will allow you to enter in a person's name and their phone number.
How many entries would you like to store?
5

Okay, you can store 5 names and phone numbers.

Please enter a name: John
Please enter their phone number: 455-0123

Please enter a name: Edward
Please enter their phone number: 455-0987

Please enter a name: Blanca
Please enter their phone number: 455-3456

Please enter a name: William
Please enter their phone number: 455-0000

Please enter a name: Pete
Please enter their phone number: 455-9999

Information is now saved to a separate file: phonebook.txt
  ----jGRASP: operation complete.


Step by Step Solution

3.40 Rating (153 Votes )

There are 3 Steps involved in it

Step: 1

Based on the requirements and expected output heres a Java program that fulfills the given instructi... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual C# An Introduction to Object-Oriented Programming

Authors: Joyce Farrell

7th edition

978-1337102100

More Books

Students also viewed these Programming questions