I keep on getting the following error, I've tried modifying the constructor, but I can't get it to work.

"C:\Users\Documents\NetBeansProjects\Assignment-1\src\Bank.java:34: cannot find symbol
symbol : constructor Customer(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)
location: class Customer
Customer customer = new Customer(last, first, street, city, state, z, acctNum);
1 error
BUILD FAILED (total time: 0 seconds)


"

import javax.swing.JOptionPane;
import java.util.ArrayList;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;

class Bank{

    public static void main(String[] arg) {
        boolean done = false;

        final String menu = "1. New Account\n2. Close Account\n3. Active Accounts\n4. Inactive Accounts\n5. Exit";

        Database db = new Database();
        Database close = new Database();


        while (!done) {
            int option = GetData.getInt(menu);

            switch (option) {
                case 1:

                    String last = GetData.getWord("Enter last name:");
                    String first = GetData.getWord("Enter first name:");

                    String street = GetData.getWord("Enter street address:");
                    String city = GetData.getWord("Enter city:");
                    String state = GetData.getWord ("Enter state:");
                    String z = GetData.getWord("Enter zip code:");

                    String acctNum = GetData.getWord("Enter an account number:");

                    [B]Customer customer = new Customer(last, first, street, city, state, z, acctNum);[/B]
                    db.add(customer);
                    break;

                case 2:
                    if (!db.empty()) {
                        acctNum = GetData.getWord("Enter account number:");
                        db.search(acctNum);

                        if (!db.inList()) {
                            acctNum = "Account number  " + acctNum;
                            display("Account number not valid", "Message", JOptionPane.ERROR_MESSAGE);
                        } else {
                            int index = db.getIndex();

                            Customer c = (Customer) db.remove(index);
                            close.add(c);
                        }
                    } else {
                        display("At this point in time, there exists no accounts. Press 'OK' to continue.", "Message", JOptionPane.ERROR_MESSAGE);
                    }
                    break;

                case 3:
                    ArrayList list = db.getList();
                    String str = "Active accounts:\n" + report(list);

                    JTextArea text = new JTextArea(str, 10, 30);
                    JScrollPane pane = new JScrollPane(text);
                    display(pane, "Report", JOptionPane.INFORMATION_MESSAGE);
                    break;

                case 4:
                    ArrayList listd = close.getList();
                    String strd = "Inactive accounts:\n" + report(listd);

                    JTextArea textd = new JTextArea(strd, 10, 30);
                    JScrollPane paned = new JScrollPane(textd);
                    display(paned, "Report", JOptionPane.INFORMATION_MESSAGE);
                    break;

                
                case 5:
                    display("Press 'OK' to quit", "Message", JOptionPane.WARNING_MESSAGE);
                    done = true;
                    break;

                default:
                    display("Wrong option.", "Message", JOptionPane.ERROR_MESSAGE);
                    break;
            }
        }
    }

    static String report(ArrayList list) {
        int length = list.size();
        String str = "";

        for (int i = 0; i < length; i++) {
            Customer s = (Customer) list.get(i);
            str = str + s.getName() + " " + s.getAddress() + "  " + s.getacctNum() + "\n";
        }
        return str;
    }

    static void display(String info, String heading, int type) {
        JOptionPane.showMessageDialog(null, info, heading, type);

    }

    static void display(JScrollPane pane, String heading, int type) {
        JOptionPane.showMessageDialog(null, pane, heading, type);
    }
}
           

class Customer {

    String acctNum;
    String firstname, lastname;
    Name name;
    Address address;

    Customer(Name name, Address address, String aNum) {
        this.acctNum = aNum;
        this.name = name;
        this.address = address;



    }

    String getacctNum() {
        return acctNum;

    }

    Name getName(){
        return name;
    }

    Address getAddress(){
        return address;
    }
//    String getfirstname() {
  //      return firstname;
    //}

    //String getlastname() {
      //  return lastname;
   // }
}


public class Name {

    String firstname, lastname;

    Name(String L, String f) {

        firstname = f;
        lastname = L;

    }

    String getfirstname() {
        return firstname;
    }

    String getlastname() {
        return lastname;
    }
}


public class Address {
   String street, city, state, zip;

   Address(String st, String c, String s, String z) {

        street = st;
        city = c;
        state = s;
        zip = z;
    }
    String getstreet(){
        return street;
    }

    String getcity(){
        return city;
    }

    String getstate(){
        return state;
    }
    String getzip(){
        return zip;
    }
}
Customer customer = new Customer(last, first, street, city, state, z, acctNum);

This code uses 7 argument Constructor - So, you have to create another constructor which takes seven arguements.

Your Customer constructor requires a Name and an Address, but you have just provided the raw information (last ... zip).
You have to create a Name and Address from the raw data and pass that to Customer

Name n = new Name(last, first);
Address a = new Address(street, city, state, z);
Customer customer = new Customer(n, a, acctNum);
// or just
Customer customer = new Customer( new Name(last, first), new Address(street, city, state, z), acctNum);

that worked, thank you, but now I've run into another problem.

The program compiles.
After I input the information and want to view it. It get random character for Name and Address.

import javax.swing.JOptionPane;
class GetData {

    static String str;
/**
    static double getWord(String s) {
        str = JOptionPane.showInputDialog(s);
        return Double.parseDouble(str);
    }
**/
    static String getWord(String s) {
        return JOptionPane.showInputDialog(s);
    }

    static int getInt(String s) {
        str = JOptionPane.showInputDialog(s);
        return Integer.parseInt(str);
    }
}

import javax.swing.JOptionPane;
import java.util.ArrayList;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;

class Bank{

    public static void main(String[] arg) {
        boolean done = false;

        final String menu = "1. New Account\n2. Close Account\n3. Active Accounts\n4. Inactive Accounts\n5. Exit";

        Database db = new Database();
        Database close = new Database();


        while (!done) {
            int option = GetData.getInt(menu);

            switch (option) {
                case 1:

                    String last = GetData.getWord("Enter last name:");
                    String first = GetData.getWord("Enter first name:");

                    String street = GetData.getWord("Enter street address:");
                    String city = GetData.getWord("Enter city:");
                    String state = GetData.getWord ("Enter state:");
                    String z = GetData.getWord("Enter zip code:");

                    String acctNum = GetData.getWord("Enter an account number:");

                    Name n = new Name(last, first);
                    Address a = new Address(street, city, state, z);
                    Customer customer = new Customer(n, a, acctNum);

                    db.add(customer);
                    break;

                case 2:
                    if (!db.empty()) {
                        acctNum = GetData.getWord("Enter account number:");
                        db.search(acctNum);

                        if (!db.inList()) {
                            acctNum = "Account number  " + acctNum;
                            display("Account number not valid", "Message", JOptionPane.ERROR_MESSAGE);
                        } else {
                            int index = db.getIndex();

                            Customer c = (Customer) db.remove(index);
                            close.add(c);
                        }
                    } else {
                        display("At this point in time, there exists no accounts. Press 'OK' to continue.", "Message", JOptionPane.ERROR_MESSAGE);
                    }
                    break;

                case 3:
                    ArrayList list = db.getList();
                    String str = "Active accounts:\n" + report(list);

                    JTextArea text = new JTextArea(str, 10, 30);
                    JScrollPane pane = new JScrollPane(text);
                    display(pane, "Report", JOptionPane.INFORMATION_MESSAGE);
                    break;

                case 4:
                    ArrayList listd = close.getList();
                    String strd = "Inactive accounts:\n" + report(listd);

                    JTextArea textd = new JTextArea(strd, 10, 30);
                    JScrollPane paned = new JScrollPane(textd);
                    display(paned, "Report", JOptionPane.INFORMATION_MESSAGE);
                    break;

                
                case 5:
                    display("Press 'OK' to quit", "Message", JOptionPane.WARNING_MESSAGE);
                    done = true;
                    break;

                default:
                    display("Wrong option.", "Message", JOptionPane.ERROR_MESSAGE);
                    break;
            }
        }
    }

    static String report(ArrayList list) {
        int length = list.size();
        String str = "";

        for (int i = 0; i < length; i++) {
            Customer s = (Customer) list.get(i);
[B]            str = str + s.getName() + " " + s.getAddress() + "  " + s.getacctNum() + "\n";[/B]
            //str = str + s.getName() + " " + s.getAddress() + "  " + s.getacctNum() + "\n";
        }
        return str;
    }

    static void display(String info, String heading, int type) {
        JOptionPane.showMessageDialog(null, info, heading, type);

    }

    static void display(JScrollPane pane, String heading, int type) {
        JOptionPane.showMessageDialog(null, pane, heading, type);
    }
}

class Customer {

    String acctNum;
    String firstname, lastname;
    Name name;
    Address address;

    Customer(Name name, Address address, String aNum) {
        this.acctNum = aNum;
        this.name = name;
        this.address = address;



    }

    String getacctNum() {
        return acctNum;

    }

    Name getName(){
        return name;
    }

    Address getAddress(){
        return address;
    }
//    String getfirstname() {
  //      return firstname;
    //}

    //String getlastname() {
      //  return lastname;
   // }
}


public class Name {

    String firstname, lastname;

    Name(String L, String f) {

        firstname = f;
        lastname = L;

    }

    String getfirstname() {
        return firstname;
    }

    String getlastname() {
        return lastname;
    }
}


public class Address {
   String street, city, state, zip;

   Address(String st, String c, String s, String z) {

        street = st;
        city = c;
        state = s;
        zip = z;
    }
    String getstreet(){
        return street;
    }

    String getcity(){
        return city;
    }

    String getstate(){
        return state;
    }
    String getzip(){
        return zip;
    }
}

For example I would get something like this:
Name@1b09468 Address@1df5a8f 123

The program would display the information properly before I applied the Name and Address class, since it was all under the Customer class.
The Account number does show up properly. It's just the name and address.

Thats because you haven't have implemented the toString method for your objects Address and Name. You need to implement them to define the behaviour of the toString method for your object. For e.g: for the Name object it could be :

public String toString(){
    return this.firstName + " " + this.lastName;
}

In case you do not provide such an information the toString() method as defined in the Object class would be executed, which just returns a string representation of the object concerned.

Note : Incase you are worried from where does the question of the toString method getting called arises in the first place, well that is the method that would be called when you attempt tp print out a copy of that object.

I forgot about that, thank you sir.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.