Question

1. You must start your pgram with header comments that provide your name, date the program...

1. You must start your pgram with header comments that provide your name, date the program was last modified.

2. A bank keeps track of their customers. Write a class Customer and associated constructor(s) to initialize customers as objects. Each customer object has a number of properties including: ID, last name, first name, address, and city.

3. Write a class Account and associated constructor(s) to initialize accounts as objects. A bank allows four types of accounts - checking account, savings account, business account, and credit card account. you must use enumerated data types for types of accounts.

Checking account has several properties including: ACCNumber, CustomerID, AccBalance, and DebitCardNo.

Saving accoung has several properties including: ACCNumber, CustomerID, and AccBalance.

Business account has several properties including: ACCNumber, CUstomerID, AccBalance, BusinessName, BusinessID.

Credit Card account has several properties including: CustomerID, CreditCardNo, Balance, and MaxCredit.

Write appropriate accessor and mutator methods for each of the class properties..

In the main class, write a method getDataFromFile to read data from a given file. This method should read data from the file, create appropriate objects for the customer and account, save the data into an array.

Write a method displayAccounts that displays all customers and their accounts information. Make sure to properly format the output.

Main: This method should be used to call all other methods and formatting output if necessary.

This is the information that has to be used for getDataFromFile

C8392380567 Sage, Amy Ping Ting Road Edmonton Checking 873387 5000 0000-6666-6666-6666

C8954385123 Lee, Bob Texaco Road Calgary Savings 827366 9480

C2389490434 Neil, Carson Deerfoot Trail Otawa Business 763655 65000 Emporia LLC 87-927736

C9384899234 Ko, David Unversity Drive Stillwater CreditCard 7667-9899-8776-1234 430 4000

C0930238083 Warren, John Ogden Road Tyler Checking 726615 1230 0000-2222-2222-2222

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

package com.HomeworkLib.bank.enu;

/*

* Chandrababu

* 27 Jan 2018

*/

public enum BusinessAccount {

Instance;

private String ACCNumber;

private String CUstomerID;

private String AccBalance;

private String BusinessName;

private String BusinessID;

public String getACCNumber() {

return ACCNumber;

}

public void setACCNumber(String aCCNumber) {

ACCNumber = aCCNumber;

}

public String getCUstomerID() {

return CUstomerID;

}

public void setCUstomerID(String cUstomerID) {

CUstomerID = cUstomerID;

}

public String getAccBalance() {

return AccBalance;

}

public void setAccBalance(String accBalance) {

AccBalance = accBalance;

}

public String getBusinessName() {

return BusinessName;

}

public void setBusinessName(String businessName) {

BusinessName = businessName;

}

public String getBusinessID() {

return BusinessID;

}

public void setBusinessID(String businessID) {

BusinessID = businessID;

}

@Override

public String toString() {

return ACCNumber+" "+CUstomerID+" "+AccBalance+" "+BusinessName+" "+BusinessID;

}

}

package com.HomeworkLib.bank.enu;

/*

* Chandrababu

* 27 Jan 2018

*/

public enum CheckingAccount {

Instance;

private String ACCNumber;

private String CustomerID;

private String AccBalance;

private String DebitCardNo;

public String getACCNumber() {

return ACCNumber;

}

public void setACCNumber(String aCCNumber) {

ACCNumber = aCCNumber;

}

public String getCustomerID() {

return CustomerID;

}

public void setCustomerID(String customerID) {

CustomerID = customerID;

}

public String getAccBalance() {

return AccBalance;

}

public void setAccBalance(String accBalance) {

AccBalance = accBalance;

}

public String getDebitCardNo() {

return DebitCardNo;

}

public void setDebitCardNo(String debitCardNo) {

DebitCardNo = debitCardNo;

}

@Override

public String toString() {

return ACCNumber+" "+CustomerID+" "+AccBalance+" "+DebitCardNo;

}

}

package com.HomeworkLib.bank.enu;

/*

* Chandrababu

* 27 Jan 2018

*/

public enum CreditCardAccount {

Instance;

private String CustomerID;

private String CreditCardNo;

private String Balance;

private String MaxCredit;

public String getCustomerID() {

return CustomerID;

}

public void setCustomerID(String customerID) {

CustomerID = customerID;

}

public String getCreditCardNo() {

return CreditCardNo;

}

public void setCreditCardNo(String creditCardNo) {

CreditCardNo = creditCardNo;

}

public String getBalance() {

return Balance;

}

public void setBalance(String balance) {

Balance = balance;

}

public String getMaxCredit() {

return MaxCredit;

}

public void setMaxCredit(String maxCredit) {

MaxCredit = maxCredit;

}

@Override

public String toString() {

return CustomerID+" "+CreditCardNo+" "+Balance+" "+MaxCredit;

}

}

package com.HomeworkLib.bank.enu;

/*

* Chandrababu

* 27 Jan 2018

*/

public enum SavingsAccount {

Instance;

private String ACCNumber;

private String CustomerID;

private String AccBalance;

public String getACCNumber() {

return ACCNumber;

}

public void setACCNumber(String aCCNumber) {

ACCNumber = aCCNumber;

}

public String getCustomerID() {

return CustomerID;

}

public void setCustomerID(String customerID) {

CustomerID = customerID;

}

public String getAccBalance() {

return AccBalance;

}

public void setAccBalance(String accBalance) {

AccBalance = accBalance;

}

@Override

public String toString() {

return ACCNumber+""+CustomerID+""+AccBalance;

}

}

package com.HomeworkLib.bank;

/*

* Chandrababu

* 27 Jan 2018

*/

public class Customer {

private String ID;

private String last_name;

private String first_name;

private String address;

private String city;

public Customer(String iD, String last_name, String first_name,

String address, String city) {

super();

ID = iD;

this.last_name = last_name;

this.first_name = first_name;

this.address = address;

this.city = city;

}

public String getID() {

return ID;

}

public void setID(String iD) {

ID = iD;

}

public String getLast_name() {

return last_name;

}

public void setLast_name(String last_name) {

this.last_name = last_name;

}

public String getFirst_name() {

return first_name;

}

public void setFirst_name(String first_name) {

this.first_name = first_name;

}

public String getAddress() {

return address;

}

public void setAddress(String address) {

this.address = address;

}

public String getCity() {

return city;

}

public void setCity(String city) {

this.city = city;

}

}

package com.HomeworkLib.bank;

import com.HomeworkLib.bank.enu.BusinessAccount;

import com.HomeworkLib.bank.enu.CheckingAccount;

import com.HomeworkLib.bank.enu.CreditCardAccount;

import com.HomeworkLib.bank.enu.SavingsAccount;

/*

* Chandrababu

* 27 Jan 2018

*/

public class Account {

private BusinessAccount businessAccount;

private CheckingAccount checkingAccount;

private CreditCardAccount creditCardAccount;

private SavingsAccount savingsAccount;

public Account(BusinessAccount businessAccount,

CheckingAccount checkingAccount,

CreditCardAccount creditCardAccount, SavingsAccount savingsAccount) {

super();

this.businessAccount = businessAccount;

this.checkingAccount = checkingAccount;

this.creditCardAccount = creditCardAccount;

this.savingsAccount = savingsAccount;

}

public BusinessAccount getBusinessAccount() {

return businessAccount;

}

public CheckingAccount getCheckingAccount() {

return checkingAccount;

}

public CreditCardAccount getCreditCardAccount() {

return creditCardAccount;

}

public SavingsAccount getSavingsAccount() {

return savingsAccount;

}

}

package com.HomeworkLib.bank;

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;

import com.HomeworkLib.bank.enu.BusinessAccount;

import com.HomeworkLib.bank.enu.CheckingAccount;

import com.HomeworkLib.bank.enu.CreditCardAccount;

import com.HomeworkLib.bank.enu.SavingsAccount;

/*

* Chandrababu

* 27 Jan 2018

*/

public class MainTest {

/**

* @param args

*/

public static void main(String[] args) {

MainTest mainTest = new MainTest();

mainTest.getDataFromFile();

}

public Object getDataFromFile() {

BufferedReader reader = null;

try {

reader = new BufferedReader(new FileReader(

"D:\\Chegg\\Jan27\\getAccountData.txt"));

String line = reader.readLine();

while (line != null) {

line = reader.readLine();

if (line != null) {

if (line.contains("Checking")) {

String check[] = line.split(",");

if (check != null && check.length > 0) {

String check1[] = check[0].split(" ");

CheckingAccount checkingAccount = CheckingAccount.Instance;

checkingAccount.setCustomerID(check1[0]);

String check2[] = check[1].split("Checking ");

String check3[] = check2[0].split(" ");

checkingAccount.setACCNumber(check3[0]);

checkingAccount.setAccBalance(check3[1]);

checkingAccount.setDebitCardNo(check3[2]);

displayAccounts(checkingAccount);

}

} else if (line.contains("Savings")) {

String check[] = line.split(",");

if (check != null && check.length > 0) {

String check1[] = check[0].split(" ");

SavingsAccount savingsAccount = SavingsAccount.Instance;

savingsAccount.setCustomerID(check1[0]);

String check2[] = check[1].split("Savings ");

String check3[] = check2[1].split(" ");

savingsAccount.setACCNumber(check3[0]);

savingsAccount.setAccBalance(check3[1]);

displayAccounts(savingsAccount);

}

} else if (line.contains("Business")) {

String check[] = line.split(",");

if (check != null && check.length > 0) {

String check1[] = check[0].split(" ");

BusinessAccount businessAccount = BusinessAccount.Instance;

businessAccount.setCUstomerID(check1[0]);

String check2[] = check[1].split("Business ");

String check3[] = check2[1].split(" ");

businessAccount.setACCNumber(check3[0]);

businessAccount.setAccBalance(check3[1]);

businessAccount.setBusinessName(check3[2]);

businessAccount.setBusinessID(check3[3]);

displayAccounts(businessAccount);

}

} else if (line.contains("CreditCard")) {

String check[] = line.split(",");

if (check != null && check.length > 0) {

String check1[] = check[0].split(" ");

CreditCardAccount creditCardAccount = CreditCardAccount.Instance;

creditCardAccount.setCustomerID(check1[0]);

String check2[] = check[1].split("CreditCard ");

String check3[] = check2[0].split(" ");

creditCardAccount.setCreditCardNo(check3[0]);

creditCardAccount.setBalance(check3[1]);

creditCardAccount.setMaxCredit(check3[2]);

displayAccounts(creditCardAccount);

}

}

}

// read next line

}

reader.close();

} catch (IOException e) {

e.printStackTrace();

}

return reader;

}

public static void displayAccounts(Object object) {

System.out.println(object.toString());

}

}

Add a comment
Know the answer?
Add Answer to:
1. You must start your pgram with header comments that provide your name, date the program...
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
  • 1- Write a code for a banking program. a) In this question, first, you need to...

    1- Write a code for a banking program. a) In this question, first, you need to create a Customer class, this class should have: • 2 private attributes: name (String) and balance (double) • Parametrized constructor to initialize the attributes • Methods: i. public String toString() that gives back the name and balance ii. public void addPercentage; this method will take a percentage value and add it to the balance b) Second, you will create a driver class and ask...

  • code must be in java. Assignment 5 Purpose In this assignment, you will implement a class...

    code must be in java. Assignment 5 Purpose In this assignment, you will implement a class hierarchy in Java. Instructions The class hierarchy you will implement is shown below account Package Account manager Package SavingAccount CheckingAccount AccountManager The descriptions of each class and the corresponding members are provided below. Please note that the Visibility Modifiers (public, private and protected) are not specified and you must use the most appropriate modifiers Class AccountManager is a test main program. Create it so...

  • This is for Java Programming Please use comments Customer and Employee data (15 pts) Problem Description:...

    This is for Java Programming Please use comments Customer and Employee data (15 pts) Problem Description: Write a program that uses inheritance features of object-oriented programming, including method overriding and polymorphism. Console Welcome to the Person Tester application Create customer or employee? (c/e): c Enter first name: Frank Enter last name: Jones Enter email address: frank44@ hot mail. com Customer number: M10293 You entered: Name: Frank Jones Email: frank44@hot mail . com Customer number: M10293 Continue? (y/n): y Create customer...

  • In C++, Step 1: Implement the Student Class and write a simple main() driver program to...

    In C++, Step 1: Implement the Student Class and write a simple main() driver program to instantiate several objects of this class, populate each object, and display the information for each object. The defintion of the student class should be written in an individual header (i.e. student.h) file and the implementation of the methods of the student class should be written in a corresponding source (i.e. student.cpp) file. Student class - The name of the class should be Student. -...

  • Write a program in C++ with comments! Create an abstract class Property, containing the data items...

    Write a program in C++ with comments! Create an abstract class Property, containing the data items owner, address and price. Add an abstract method showOwner(). Also provide getter/setters for all the data items. Make validations if necessary in the setter so that no invalid values are entered. Create a class House, to inherit the Property class. This class should contain additional data item – yardSize – an integer – the size of the yard of the house, getter and setter...

  • When answering this question, can you please specify what you name your files? Thank you! Write a...

    When answering this question, can you please specify what you name your files? Thank you! Write a Java application, and an additional class to represent some real-world entity. Keep in mind that a class is a model in code of something real or imagined, which has attributes (member variables) and behaviors (member methods). The class will: a. Create a total of 5 member variables for the class, selecting the appropriate data types for each field. For example, a class to...

  • Textbook help its not in textbook solutions from the textbook C++ Programming 7th edition Malik,D.S Chapter...

    Textbook help its not in textbook solutions from the textbook C++ Programming 7th edition Malik,D.S Chapter 12 programming exercise 5 Banks offer various types of accounts, such as savings, checking, certificateof deposits, and money market, to attract customers as well as meet their specific needs. Two of the most commonly used accounts are savings andchecking. Each of these accounts has various options. For example, you mayhave a savings account that requires no minimum balance but has a lower interest rate....

  • *Step1: -Create UML of data type classes: reuse from lab3 for class Account, CheckingAccount and SavingAccount...

    *Step1: -Create UML of data type classes: reuse from lab3 for class Account, CheckingAccount and SavingAccount -Read the requirement of each part; write the pseudo-code in a word document by listing the step by step what you suppose to do in main() and then save it with the name as Lab4_pseudoCode_yourLastName *Step2: -start editor eClipse, create the project→project name: FA2019_LAB4PART1_yourLastName(part1) OR FA2019_LAB4PART2_yourLastName (part2) -add data type classes (You can use these classes from lab3) Account_yourLastName.java CheckingAccount_yourLastName.java SavingAccount_yourLastName.java -Add data structure...

  • Write a python program using Object Oriented and do the following: 1. create class "cat" with...

    Write a python program using Object Oriented and do the following: 1. create class "cat" with the following properties: name, age (create constructor method: def __init__) 2. create class "adopter" with the following properties: name, phone 3. create class "transaction" with these properties: adopter, cat (above objects) cat1 = "puffy, 2" adopter1 = "Joe, 123" Test your program: Joe adopts puffy. Print: "Per Transaction 1 <joe> has adopted <puffy>" this can only be done with object oriented programming, no way...

  • Java coding help! Write a program to simulate a bank which includes the following. Include a...

    Java coding help! Write a program to simulate a bank which includes the following. Include a commented header section at the top of each class file which includes your name, and a brief description of the class and program. Create the following classes: Bank Customer Account At a minimum include the following data fields for each class: o Bank Routing number Customer First name Last name Account Account number Balance Minimum balance Overdraft fee At a minimum write the following...

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