Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Simple java program: Topic: Binary File I/O Create a simple application called c

ID: 3936692 • Letter: S

Question

Simple java program:

Topic: Binary File I/O

Create a simple application called contact list that will accept a person’s first and last name from a dialog box, the accept a phone number from a dialog box.

Now save that information to a binary file.

You’ll only have one record.
----------------------------

Next,

Go back to your contact list application modify it such that that will accept a person’s first and last name from a dialog box, then accept a phone number from a dialog box. It will repeat this process until the user types in some sentinel value (terminating value) for name.

If the file doesn’t exist currently, you’ll create a new file. If it does, you’ll append to it.

Explanation / Answer

public class SimpleJava {

     string first,last, phone;

     public static void main(String[] args) throws Exception {

           String first = System.console().readLine();

           DataOutputStream out = openOutputStream("binary");

           while(!first.equals("Terminate")) {

      String last = System.console().readLine();

      String phone = System.console().readLine();

              out.writeUTF(first+last+phone);

              String first = System.console.readline();

          }

   }

  

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote