Results 1 to 5 of 5
  1. #1
    vcardell is offline Member
    Join Date
    Nov 2011
    Posts
    10
    Rep Power
    0

    Default Calling into the main method

    I'm trying call buildInstances and call createReprot into the main method and i can't can anyone help me with this issue would be greatly appreciated.


    public class CustomerTest
    {
    public static void main(String args[])
    {

    String stringArray[][] = {{"Jones","122 Cooper Street","Arlington","Virginia","53456","auto","A12 34",
    "325.00"},
    {"Smith","21A Lover Lane","Dallas","Texas","75025","life","L5467","175 .75"},
    {"Hanover","4315 Express way","Euless","Texas","73867","home","H3956","1200 .00"},
    {"Kincaid","225 Dora Lane","Tulsa","Oaklahoma","63901","auto","A2012"," 550.50"},
    {"Sierra","789 Bowen Road","New Orleans","Louisiana","53412","life","L4378","212.6 0"}};


    customer.buildInstances();//call buildinstances
    customer.creatReports();//call createReprot

    System.out.printf(cusArray);//print the answer

    }

    public static Customer[] buildInstances(String dataArray[][])
    {
    Policy.PolicyType pt = null;
    Customer cusArray[] = new Customer[dataArray.length];

    for (int i = 0; i< dataArray.length; i++)
    {

    if (dataArray[i][5].equals("auto"))
    pt = Policy.PolicyType.AUTO;

    else if (dataArray[i][5].equals("life"))
    pt = Policy.PolicyType.LIFE;

    else if (dataArray[i][5].equals("home"))
    pt = Policy.PolicyType.HOME;

    cusArray[i] = new Customer(dataArray[i][0], new Address(dataArray[i][1],dataArray[i][2],dataArray[i][3],Integer.parseInt(dataArray[i][4]), new Policy( pt, dataArray[i][6], Double.parseDouble(dataArray[i][7])));

    return cusArray;

    }
    }


    public static String CreateReport(Customer c[])
    {
    for (int i = 0; i< cusArray.length; i++)
    {
    System.out.printf(cusArray[i].toString(), get.calculateBill());
    }
    }
    }

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,525
    Blog Entries
    7
    Rep Power
    20

    Default Re: Calling into the main method

    In your main( ... ) method, what is that "customer" thing? I bet the compiler doesn't know either, so it complains about it.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    vcardell is offline Member
    Join Date
    Nov 2011
    Posts
    10
    Rep Power
    0

    Default Re: Calling into the main method

    Ok Thanks Jos....

    I think i fixed that problem now i'm getting about ten errors for
    "public static String CreateReport(Customer c[])"
    they all say the same thing "Illegal start of expression or ';' expected"

    Here is new code
    public class CustomerTest
    {
    public static void main(String args[])
    {

    String stringArray[][] = {{"Jones","122 Cooper Street","Arlington","Virginia","53456","auto","A12 34",
    "325.00"},
    {"Smith","21A Lover Lane","Dallas","Texas","75025","life","L5467","175 .75"},
    {"Hanover","4315 Express way","Euless","Texas","73867","home","H3956","1200 .00"},
    {"Kincaid","225 Dora Lane","Tulsa","Oaklahoma","63901","auto","A2012"," 550.50"},
    {"Sierra","789 Bowen Road","New Orleans","Louisiana","53412","life","L4378","212.6 0"}};


    BuildInstances myBuildInstances = new BuildInstances(dataArray);
    CreateReports myCreateReports = new CreateReports(cusArray);

    System.out.printf(cusArray, dataArray);

    }

    public static Customer[] buildInstances(String dataArray[][])
    {
    Policy.PolicyType pt = null;
    Customer cusArray[] = new Customer[dataArray.length];

    for (int i = 0; i< dataArray.length; i++)
    {

    if (dataArray[i][5].equals("auto"))
    pt = Policy.PolicyType.AUTO;

    else if (dataArray[i][5].equals("life"))
    pt = Policy.PolicyType.LIFE;

    else if (dataArray[i][5].equals("home"))
    pt = Policy.PolicyType.HOME;

    cusArray[i] = new Customer(dataArray[i][0], new Address(dataArray[i][1],dataArray[i][2],dataArray[i][3],Integer.parseInt(dataArray[i][4]), new Policy(pt, dataArray[i][6], Double.parseDouble(dataArray[i][7]));
    }
    return cusArray;


    }


    public static String CreateReport(Customer c[])
    {
    for (int i = 0; i< cusArray.length; i++)
    {
    System.out.printf(cusArray[i].toString(), get.calculateBill());
    }
    }
    }

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default Re: Calling into the main method

    Please use code tags in future when posting code. Place [ code ] before and [ /code ] after your code (whithout the spaces).

    Since you code is unformatted it is difficult to read. The error message leads me to believe that you have mismatching braces.

  5. #5
    vcardell is offline Member
    Join Date
    Nov 2011
    Posts
    10
    Rep Power
    0

Similar Threads

  1. Calling The main method from another method
    By SwissR in forum New To Java
    Replies: 3
    Last Post: 07-27-2010, 11:03 AM
  2. Calling main method
    By eva in forum New To Java
    Replies: 7
    Last Post: 11-06-2009, 01:37 PM
  3. calling method from main method
    By bob_bee in forum New To Java
    Replies: 4
    Last Post: 10-02-2009, 05:30 PM
  4. Calling a variable from main to another class
    By itsme in forum New To Java
    Replies: 1
    Last Post: 12-18-2007, 03:35 PM
  5. calling array from main
    By nalinda in forum New To Java
    Replies: 1
    Last Post: 11-17-2007, 09:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •