Question

Customer Accounts This program should be designed and written by a team of students. Here are...

Customer Accounts

This program should be designed and written by a team of students. Here are some

suggestions:

Write a program that uses a structure to store the following information about a

customer account:

• Name

• Address

• City, state, and ZIP

• Telephone number

• Account balance

• Date of last payment

The structure should be used to store customer account records in a file. The program

should have a menu that lets the user perform the following operations:

• Enter new records into the file

• Search for a particular customer's record and display it

• Search for a particular customer's record and delete it

• Search for a particular customer's record and change it

• Display the contents of the entire file

Input Validation: When the information for a new account is entered, be sure the

user enters data for all the fields. No negative account balances should be entered.

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

Short Summary:

Implemented the program as per requirement in java(as the language is not mentioned in the question)
Attached source code and sample output


**************Please do upvote to appreciate our time. Thank you!******************

Source Code:

import java.util.ArrayList;
import java.util.Date;
import java.util.ListIterator;
import java.util.Scanner;

/**This class stores the below values of customer**/
public class Customer {

   private String name;
   private String address;
   private String city;
   private String state;
   private String zip;
   private String phone;
   private double acctBalance;
   private Date dateOfPayment;

   /**Constructor**/
   public Customer(String name, String address, String city, String state, String zip, String phone,
           double acctBalance, Date dateOfPayment) {
       this.name = name;
       this.address = address;
       this.city = city;
       this.state = state;
       this.zip = zip;
       this.phone = phone;
       this.acctBalance = acctBalance;
       this.dateOfPayment = dateOfPayment;
   }
//Accessors
   public String getName() {
       return name;
   }

   public String getAddress() {
       return address;
   }

   public String getCity() {
       return city;
   }

   public String getState() {
       return state;
   }

   public String getZip() {
       return zip;
   }

   public String getPhone() {
       return phone;
   }

   public double getAcctBalance() {
       return acctBalance;
   }

   public Date getDateOfPayment() {
       return dateOfPayment;
   }


   public static void main(String args[])
   {

       //Scanner to get user input
       Scanner input=new Scanner(System.in);

       ArrayList <Customer> custList=new ArrayList<Customer>();

       int choice=1;

       //Loop until choice is zero to quit
       while(choice!=0)
       {
           System.out.println("1. Enter new record\n2. Display a customer record\n3. Delete a record\n4. Change a record\n5. Display all records\nEnter your choice or 0 to quit: ");
           choice=input.nextInt();

           input.nextLine();
           switch(choice)
           {
           case 1:

               System.out.println("Enter customer name: ");
               String username=input.nextLine();
               System.out.println("Enter Address: ");
               String addr=input.nextLine();
               System.out.println("Enter City: ");
               String cityEntered=input.nextLine();
               System.out.println("Enter state: ");
               String stateEntered=input.nextLine();
               System.out.println("Enter zip: ");
               String zipEntered=input.nextLine();
               System.out.println("Enter phone: ");
               String phoneNo=input.nextLine();
               double balance=0;

               boolean valid=false;
               //Validate acct balance
               while(!valid)
               {
                   System.out.println("Enter account balance: ");
                   balance=input.nextDouble();
                   input.nextLine();
                   if(balance<0)
                       System.out.println("Account balance cannot be negative!");
                   else
                       valid=true;
               }

               Customer cust=new Customer(username, addr, cityEntered, stateEntered, zipEntered, phoneNo,balance, new Date());
               custList.add(cust);
               break;
           case 2:
               System.out.println("Enter customer Name: ");
               String nameEntered=input.nextLine();
               for(Customer custObj:custList)
               {
                   if(custObj.getName().equalsIgnoreCase(nameEntered))
                       System.out.println(custObj.toString());
               }
               break;
           case 3:
               System.out.println("Enter the customer name you want to delete: ");
               nameEntered=input.nextLine();
               ListIterator<Customer> litr =custList.listIterator();

                   while(litr.hasNext())
                   {
                       Customer custObj=litr.next();
                       if(custObj.getName().equalsIgnoreCase(nameEntered))
                       {
                           custList.remove(custObj);
                       }
                   }
               break;
           case 4:
               System.out.println("Enter the customer name you want to update: ");
               nameEntered=input.nextLine();
               ListIterator<Customer> litr1 =custList.listIterator();

               while(litr1.hasNext())
               {
                   Customer custObj=litr1.next();
                   if(custObj.getName().equalsIgnoreCase(nameEntered))
                   {
                       custList.remove(custObj);
                   }
               }
               System.out.println("Enter new details below:");
               System.out.println("Enter Address: ");
               addr=input.nextLine();
               System.out.println("Enter City: ");
               cityEntered=input.nextLine();
               System.out.println("Enter state: ");
               stateEntered=input.nextLine();
               System.out.println("Enter zip: ");
               zipEntered=input.nextLine();
               System.out.println("Enter phone: ");
               phoneNo=input.nextLine();
               System.out.println("Enter account balance: ");
               balance=input.nextDouble();
               input.nextLine();
               cust=new Customer(nameEntered, addr, cityEntered, stateEntered, zipEntered, phoneNo,balance, new Date());
               custList.add(cust);  
               break;
           case 5:
               System.out.println(custList.toString());
               break;

           }
       }

   }

   @Override
   public String toString() {
       return "Customer [name=" + name + ", address=" + address + ", city=" + city + ", state=" + state + ", zip="
               + zip + ", phone=" + phone + ", acctBalance=" + acctBalance + ", dateOfPayment=" + dateOfPayment + "]\n";
   }


}

Code Screenshot:

3 import java.util.ArrayList; 4 import java.util.Date; 5 import java.util.ListIterator; 6 import java.util.Scanner; 7 8 /**Th

42 43 puviil JLI 1118 ECLLILY return city; } 44 public String getState() { return state; } public String getZip() { return zi

choice=input.nextInt(); input.nextLine(); switch(choice) { case 1: 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9

150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 1790 180

Output:

<terminated> Customer (Java Application] C:\Program Files\Java\jre1.8.0_261\bin\javaw.exe (Oct 27, 2020, 1:16:34 AM) 1. Enter
<terminated Customer (Java Application] C:\Program Files Vava jre1.8.0_201\binjavaw.exe (Oct 21, 2020, 1:16:34 AM) Enter stat

Enter the customer name you want to delete: John 1. Enter new record 2. Display a customer record 3. Delete a record 4. Chang

**************Please do upvote to appreciate our time. Thank you!******************

Add a comment
Know the answer?
Add Answer to:
Customer Accounts This program should be designed and written by a team of students. Here are...
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
  • Write a program that uses a structure to store the following data about a customer account: Name Address City, sta...

    Write a program that uses a structure to store the following data about a customer account: Name Address City, state, and ZIP Telephone number Account Balance Date of last payment The program should use an vector of at least 20 structures. It should let the user enter data into the vector, change the contents of any element, and display all the data stored in the array. The program should have a menu-driven user interface. Input Validation: When the data for...

  • Write a program that keeps track of a speakers’ bureau. The program should use a structure...

    Write a program that keeps track of a speakers’ bureau. The program should use a structure to store the following data about a speaker: (this is in C++) Name Telephone Number Speaking Topic Fee Required The program should use a vector of structures. It should let the user enter data into the vector, change the contents of any element, and display all the data stored in the vector. The program should have a menu-driven user interface. Input Validation: When the...

  • Inventory Program (C++) Write a program that uses a structure to store the following inventory data...

    Inventory Program (C++) Write a program that uses a structure to store the following inventory data in a file: - Item Description -Quantity on Hand -Wholesale cost -Retail cost -Date Added to Inventory The program should have a menu that allows the user to perform the following tasks: -Add new records to file -Display any record in the file -Change any record in the file Input Validation: The program should not accept quantities, or wholesale or retail costs, less than...

  • Serendipity Engineering, Inc. Software Development Project Program Specifications: Serendipity Engineering, Inc. is a small engineering company...

    Serendipity Engineering, Inc. Software Development Project Program Specifications: Serendipity Engineering, Inc. is a small engineering company located in a commercial park. The project manager wants you to develop a customer software package that will allow the company enter the customer information in the computer to keep a customer database. The software will perform the following tasks using menus: Enter Customer Information Display Customer Information Search Customer Information Organize (Sort) Customer Information Add, Delete, Modify, and Look Up Customer Records Save...

  • Write a program (C++) that shows Game sales. The program should use a structure to store...

    Write a program (C++) that shows Game sales. The program should use a structure to store the following data about the Game sale: Game company Type of Game (Action, Adventure, Sports etc.) Year of Sale Sale Price The program should use an array of at least 3 structures (3 variables of the same structure). It should let the user enter data into the array, change the contents of any element and display the data stored in the array. The program...

  • C++ program Write a C++ program to manage a hospital system, the system mainly uses file...

    C++ program Write a C++ program to manage a hospital system, the system mainly uses file handling to perform basic operations like how to add, edit, search, and delete record. Write the following functions: 1. hospital_menu: This function will display the following menu and prompt the user to enter her/his option. The system will keep showing the menu repeatedly until the user selects option 'e' from the menu. Arkansas Children Hospital a. Add new patient record b. Search record c....

  • please write in C++ Write a program that uses a structure to store the following inventory...

    please write in C++ Write a program that uses a structure to store the following inventory data in a file: The data can be either read from a text file or the keyboard Item name (string) Quantity on hand(int) Wholesale cost(double) Retail Cost(double) The program should have a menu that allows the user to perform the following tasks: Add new records to the file Display any record in the file User will provide the name of the item or the...

  • In C++ write a simple menu program that displays a menu for the user in an...

    In C++ write a simple menu program that displays a menu for the user in an object-oriented technique. The menu should keep showing up until the user chooses to quit. Also, there is a sub-menu inside a menu. The user should get at least a line displayed after he or she chooses that particular option meaning if the user presses 1 for the read actors from the file. The output can look like "reading actors from a file" and then...

  • I need help with this code. I'm using C++ and Myprogramming lab to execute it. 11.7:...

    I need help with this code. I'm using C++ and Myprogramming lab to execute it. 11.7: Customer Accounts Write a program that uses a structure to store the following data about a customer account:      Customer name      Customer address      City      State      ZIP code      Telephone      Account balance      Date of last payment The program should use an array of at least 20 structures. It should let the user enter data into the array, change the contents of any element, and display all the...

  • Write a Java program that creates and manipulates a directory of names, telephone numbers. The following...

    Write a Java program that creates and manipulates a directory of names, telephone numbers. The following information will be stored for each person in the directory: - Name (Last, First) - Home telephone number You should keep the entire collection ordered by key value (the combination of last and first names). Your program should be able to perform the following basic functions: - Search and display the contents of a particular entry - Display the entire directory - Delete an...

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