Question

In: Computer Science

Create a program that allows a user to input customer records (ID number, first name, last...

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. When you run the main program, be sure to enter multiple records.

Once you create the file, open it and display the results to the user

Save the file as  CustomerList.java

Solutions

Expert Solution

import java.io.File;
import java.io.PrintWriter;
import java.util.Scanner;

public class CustomerList {
   public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
       PrintWriter pw = new PrintWriter(new File("output.txt"));
       int id;
       String fname, lname;
       double balance;
       String ch = "y";
       //reading the data
       while (ch.equalsIgnoreCase("y")) {
           System.out.println("Enter Id: ");
           id = sc.nextInt();
           //reading the data from user
           System.out.println("Enter first Name and Last name");
           fname = sc.nextLine();
           fname = sc.nextLine();
           lname = sc.nextLine();
           System.out.println("Enter balance: ");
           balance = sc.nextDouble();
           //printing the data to the file
           pw.println(id + "\t" + fname + " " + lname + "\t" + balance);
           System.out.println("Press y/Y to continue, any other key to exit: ");
           ch = sc.nextLine();
           ch = sc.nextLine();
       }
       pw.close();
       //opening the file and reading and printing
       sc = new Scanner(new File("output.txt"));
       while (sc.hasNext()) {
           System.out.println(sc.nextLine());
       }
       pw.close();
   }
}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me


Related Solutions

Using RAPTOR create a program that allows the user to input a list of first names...
Using RAPTOR create a program that allows the user to input a list of first names in on array and last names into a parallel array. Input should be terminated when the user enters a sentinel character. the output should be a list of email address where the address is of the following form: [email protected]
C++ Change the program to take user input for first name and last name for five...
C++ Change the program to take user input for first name and last name for five employees. Add a loop to read the first name and last name. // EmployeeStatic.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <string> #include <iostream> #include <string> using namespace std; class Employee { public:    Employee(const std::string&, const std::string&); // constructor    ~Employee(); // destructor    std::string getFirstName() const; // return first name    std::string getLastName() const; // return...
You have been asked to write program that allows the user to input a first name,...
You have been asked to write program that allows the user to input a first name, middle initial (without the period), and last name of a user and then display that person’s name with the first, middle initial followed by a period, and last name last. BEFORE creating the program, use structured programming principles to document how you are going to develop the program. Use Microsoft Word to complete this part of the assessment. Answer each of the following areas:...
Create a program that keeps track of the following information input by the user: First Name,...
Create a program that keeps track of the following information input by the user: First Name, Last Name, Phone Number, Age Now - let's store this in a multidimensional array that will hold 10 of these contacts. So our multidimensional array will need to be 10 rows and 4 columns. You should be able to add, display and remove contacts in the array. In Java
You have been asked to write program that allows the user to input a first name, middle initial (without the period)
You have been asked to write program that allows the user to input a first name, middle initial (without the period), and last name of a user and then display that person’s name with the first, middle initial followed by a period, and last name last.BEFORE creating the program, use structured programming principles to document how you are going to develop the program. Use Microsoft Word to complete this part of the assessment. Answer each of the following areas:Solve a...
Write a program that prompts the user to input their first name from the keyboard and...
Write a program that prompts the user to input their first name from the keyboard and stores them in the variable "firstName". It does the same for last name and stores it in the variable "lastName". It then uses strcat to merge the two names, separates them by a space and stores the full name into a string variable called "fullName". In the end, the program must print out the string stored within fullName. ANSWER IN C LANGUAGE ! You...
Create a C++ program that will prompt the user to input an integer number and output...
Create a C++ program that will prompt the user to input an integer number and output the corresponding number to its numerical words. (From 0-1000000 only) **Please only use #include <iostream>, switch and if-else statements only and do not use string storing for the conversion in words. Thank you.** **Our class is still discussing on the basics of programming. Please focus only on the basics. Thank you.** Example outputs: Enter a number: 68954 Sixty Eight Thousand Nine Hundred Fifty Four...
Create a C++ program that will prompt the user to input an positive integer number and...
Create a C++ program that will prompt the user to input an positive integer number and output the corresponding number to words. Check all possible invalid input data. (Please use only switch or if-else statements. Thank you.)
Create a C++ program that will prompt the user to input an integer number and output...
Create a C++ program that will prompt the user to input an integer number and output the corresponding number to its numerical words. (From 0-1000000 only) **Please only use #include <iostream> and switch and if-else statements only. Thank you. Ex. Enter a number: 68954 Sixty Eight Thousand Nine Hundred Fifty Four Enter a number: 100000 One Hundred Thousand Enter a number: -2 Number should be from 0-1000000 only
Create a small program that contains the following. ask the user to input their name ask...
Create a small program that contains the following. ask the user to input their name ask the user to input three numbers check if their first number is between their second and third numbers
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT