Question

Please make it sure your answers are meet what question needs with details I do not accept (copy ...

Please make it sure your answers are meet what question needs with details

I do not accept (copy / post)

Using NetBeans IDE and write a CLI application that uses the BufferedWriter to write data to the file named "CustomerList.txt".

===========================================================================

The application should follow this information

A. Create a program that allows a user to input customer records (ID number, first
name, last name, and balance owed) and save each record to a file. Save the
program asWriteCustomerList.java.When you execute the program, be sure to
enter multiple records that have the same last name because you will search for
repeated first names in part d of this exercise.

===========================================================================

of the textbook that asks user for the proper input (via CLI input) of following:

  • ID number
  • First Name
  • Last Name
  • Balance owed

Note: Only do part A (the write process) of the exercise

Use following Java syntax for you file Path object:

  • Path file = Paths.get("CustomerList.txt");

Remember to catch exceptions!!!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1 to enter a record 0 to exit Enter the IDNumber: 12 Enter the First Name:abc Enter the Last Name: pqr Enter the balance owne

output to file

12 abc pqr 123
13 abc xyz 456

------------------------------------------------------------------------------------------------

import java.io.BufferedWriter;

import java.io.IOException;

import java.nio.file.Files;

import java.nio.file.Path;

import java.nio.file.Paths;

import java.util.Scanner;

public class asWriteCustomerList {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        try {

            Path file = Paths.get("CustomerList.txt");

            BufferedWriter writer = Files.newBufferedWriter(file);

            int input = -1;

            // loops unitl the user does not enters 0

            while (input != 0) {

                // provides a menu to the user

                System.out.print("\n1 to enter a record ");

                System.out.println("\n0 to exit");

                // scans the input

                input = scanner.nextInt();

                scanner.nextLine();

                // if the user entered 1

                if (input == 1) {

                    // asks the user for the id number

                    System.out.print("\nEnter the IDNumber:");

                    String id = scanner.nextLine();

                    // asks the user for the first name

                    System.out.print("\nEnter the First Name:");

                    String firstname = scanner.nextLine();

                    // asks the user for the last name

                    System.out.print("\nEnter the Last Name:");

                    String lastname = scanner.nextLine();

                    System.out.print("\nEnter the balance owned: ");

                    String balance = scanner.nextLine();

                    // writes to a file

                    writer.write("" + id + " " + firstname + " " + lastname + " " + balance);

                    writer.newLine();

                    // if the user enter 0

                } else if (input == 0) {

                    // closes the file and exit

                    writer.close();

                    break;

                }

            }

        } catch (IOException exception) {

        }

    }

}

Add a comment
Know the answer?
Add Answer to:
Please make it sure your answers are meet what question needs with details I do not accept (copy ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I've done all questions except question 6. how do I do this? please help. code needs...

    I've done all questions except question 6. how do I do this? please help. code needs to be java 1. You need to be able to open and read the text files that have been provided for the project. Write a Java program that reads the driver.txt file and displays each data value for each line from the file to the screen in the following format: Licence Number: Licence Class: First Name: Last Name: Address: Suburb: Postcode: Demerit Points: Licence...

  • Really need help from 11 on: Create the directory structure IFT383FinalExam/Activities/Activity1 in your home directory. Using...

    Really need help from 11 on: Create the directory structure IFT383FinalExam/Activities/Activity1 in your home directory. Using the cat command, create a file named classRoster with the following fields, separated by a comma. Student ID First Name Last Name Grade Program of Study ASURITE ID (username) Add three records to your file. Display the contents of the file. Move the file classRoster to the directory Activity1. Go to the Activity1 directory. Display the directory you are in. Add read, write and...

  • please make sure to write down all the coding and the output for it and to...

    please make sure to write down all the coding and the output for it and to do all three steps Student Name: 1. Write a class named Employee that holds the following data about an employee in attributes: name, ID number, department, and job title. (employee.py) 2. Create a UML diagram for Employee class. (word file) 3. Create a program that stores Employee objects in a dictionary. Use the employee ID number as the key. (employee_App.py) The program should present...

  • Modify your program from Assignment # 7 part b (see below for code) by creating an...

    Modify your program from Assignment # 7 part b (see below for code) by creating an interactive GUI application that displays the list of the orders read in from the file (create a data file using your CreateBankFile.java program which has a least 10 bank account records in it and include it with your submission) and the total number of bank accounts. When your program starts it will first read the records from the Bank Account file (AccountRecords.txt) and creates...

  • What to submit: your answers to exercises 2. Write a Java program to perform the following...

    What to submit: your answers to exercises 2. Write a Java program to perform the following tasks: The program should ask the user for the name of an input file and the name of an output file. It should then open the input file as a text file (if the input file does not exist it should throw an exception) and read the contents line by line. It should also open the output file as a text file and write...

  • Write this in a C program please. Structures on Disk The Problem Your task is to...

    Write this in a C program please. Structures on Disk The Problem Your task is to write a program that stores and retrieves structures in a file on disk. The file of structures must remain on the disk once your program ends. You should be able to store structures to the file and retrieve from the file after restarting the program. The record that you will be writing to file has the following structure: struct contact {unsigned long phone_number; long...

  • Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   please put comment with code! and please do not just copy other solu...

    Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   please put comment with code! and please do not just copy other solutions. Instructions 1. Read instructions carefully! 2. Use C++ syntax only, C syntax will not be accepted. 3. Always use braces to define blocks. 4. Indent all lines within a block. Each block requires one more tab. 5. Organize your code well with proper formatting and a single...

  • Please write comments with the program. Python programming!! Part III - write student data In this...

    Please write comments with the program. Python programming!! Part III - write student data In this part the program should create a .csv file and fill it with generated student information. The program should: Ask the user for a name for the .csv file (use your own name for the exercise) Create the .csv file with columns named - ID, first-name, GPA Based on the information received in part I, generate and fill students information in the CSV file Tell...

  • High School Assignment: please keep simple, use for loops but preferably no arrays In python, Instructions...

    High School Assignment: please keep simple, use for loops but preferably no arrays In python, Instructions Write a program to input ten book titles and author's names then save them to a file named books.txt. For each book, the user will first input the title, then input the first name, then the last name of the author, all on separate lines. In addition to saving the books in the file, please output, using the print method, the information you've gathered...

  • Mini Project You are required to do this assignment on your own skills. No copying from...

    Mini Project You are required to do this assignment on your own skills. No copying from other students are not allowed. Write a menu driven Bash script using the guidelines given below. Some of the commands and syntax may not be covered in lectures. Please refer other sources to understand syntax and commands you need to complete this assignment. This program takes user input and to perform simple arithmetic operations such as addition, subtraction, multiplication and division of any two...

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