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

    Default calling methods into my main seems to be my first problem

    Can anyone help me figure out what i am doing wrong?
    Any help would be appreciated!!!!


    Here is new code
    Java 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);
    
    }
    Java Code:
    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;
    }

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

    }



    here is error messages

    C:\myjavaclass>javac CustomerTest.java
    CustomerTest.java:13: error: cannot find symbol
    BuildInstances myBuildInstances = new BuildInstances(dataArray);

    ^
    symbol: class BuildInstances
    location: class CustomerTest
    CustomerTest.java:13: error: cannot find symbol
    BuildInstances myBuildInstances = new BuildInstances(dataArray);

    ^
    symbol: class BuildInstances
    location: class CustomerTest
    CustomerTest.java:13: error: cannot find symbol
    BuildInstances myBuildInstances = new BuildInstances(dataArray);

    ^
    symbol: variable dataArray
    location: class CustomerTest
    CustomerTest.java:14: error: cannot find symbol
    CreateReports myCreateReports = new CreateReports(cusArray);
    ^
    symbol: class CreateReports
    location: class CustomerTest
    CustomerTest.java:14: error: cannot find symbol
    CreateReports myCreateReports = new CreateReports(cusArray);
    ^
    symbol: class CreateReports
    location: class CustomerTest
    CustomerTest.java:14: error: cannot find symbol
    CreateReports myCreateReports = new CreateReports(cusArray);
    ^
    symbol: variable cusArray
    location: class CustomerTest
    CustomerTest.java:16: error: cannot find symbol
    System.out.printf(cusArray(), dataArray());
    ^
    symbol: method cusArray()
    location: class CustomerTest
    CustomerTest.java:16: error: cannot find symbol
    System.out.printf(cusArray(), dataArray());
    ^
    symbol: method dataArray()
    location: class CustomerTest
    CustomerTest.java:37: error: cannot find symbol
    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])));


    ^
    symbol: method parseDouble(String)
    location: class Double
    CustomerTest.java:47: error: cannot find symbol
    for (int i = 0; i< cusArray.length; i++)
    ^
    symbol: variable cusArray
    location: class CustomerTest
    CustomerTest.java:49: error: cannot find symbol
    System.out.printf(cusArray[i].toString(), get.calculateBill());
    ^
    symbol: variable cusArray
    location: class CustomerTest
    CustomerTest.java:49: error: cannot find symbol
    System.out.printf(cusArray[i].toString(), get.calculateBill());
    ^
    symbol: variable get
    location: class CustomerTest
    12 errors

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

    Default Re: calling methods into my main seems to be my first problem

    The error says it cannot find the BuildInstances class. DO you have a class called BuildInstances? It is not in the code you posted. You do have a buildInstances method. Which is it? What are you trying to do?

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

    Default Re: calling methods into my main seems to be my first problem

    it's in the second code on the first line

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

    Default Re: calling methods into my main seems to be my first problem

    Yes that is the buildInstances method. But you are trying to create a BuildInstances object. They are 2 completely different things. You do not have a BuildInstances class so you cannot create instances of it.

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

    Default Re: calling methods into my main seems to be my first problem

    Am I wording the question wrong?

    I'm trying to call the buildInstances method and the createReport method into the main method.

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

    Default Re: calling methods into my main seems to be my first problem

    Java Code:
    BuildInstances myBuildInstances = new BuildInstances(dataArray);
    CreateReports myCreateReports = new CreateReports(cusArray);
    Those two lines are trying to create objects not call methods. You need to do some revision on what each means.

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

    Default Re: calling methods into my main seems to be my first problem

    That's where i'm stuck at the book I have doesn't explain it clear enough for me to understand.

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

    Default Re: calling methods into my main seems to be my first problem

    Then use Google. There are plenty of tutorials and code exmaples online.

  9. #9
    gabrielpr12 is offline Member
    Join Date
    Nov 2011
    Posts
    41
    Rep Power
    0

    Default Re: calling methods into my main seems to be my first problem

    I have the same problem. How do you call a method from another method? I can't rreally find an answer online, I tried searching.

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

    Default Re: calling methods into my main seems to be my first problem

    Check my main method to see how i called them.

    Java Code:
    public class CustomerTest
    {
    	public static void main(String args[])
    	{
    		
    		String dataArray[][]= {{"Jones","122 Cooper Street","Arlington","Virginia","53456","auto","A1234","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","Oklahoma","63901", "auto","A2012","550.50"},{"Sierra","789 Bowen Road","New Orleans","Louisiana","53412","life","L4378","212.60"}};
    
    		Customer array[]=new Customer[dataArray.length];
    		
    		array=buildInstances(dataArray);
    	
    		
    		String s;
    		s= createReport(array);
    		System.out.printf("%-15s%-15s%-15s%15s\n", "Name", "State", "Policy Type","Annual Premium");
    		System.out.print(s);
    	}
    	
    	public static Customer[] buildInstances(String a[][])
    	{
    		Policy.policyType p=Policy.policyType.HOME; 
    		
    		Customer customerArray[]=new Customer[a.length];
    		for(int i=0; i < a.length;i++)
    	
    				{
    				if (a[i][5].equals("auto"))
    					p=Policy.policyType.AUTO;
    				else
    					if (a[i][5].equals("home"))
    					p=Policy.policyType.HOME;
    				else
    					if (a[i][5].equals ("life"))
    					p=Policy.policyType.LIFE;
    			
    		 customerArray[i]=new Customer(a[i][0],new Address(a[i][1],a[i][2],a[i][3],Integer.parseInt(a[i][4])), new Policy(p,a[i][6],Double.parseDouble(a[i][7])));
     
    				}
    	
    	return customerArray;
    
    
    
    	}
    
    	public static String createReport(Customer array[])
    
    		
    	{
    		String message="";
    	
    		double total=0.0;
    	
    		for(int i=0; i < array.length;i++)
    			{
    			total+=array[i].calculateBill();
    			message +=String.format("%-15s%-15s%-15s$%-15.2f\n", array[i].getName(),array[i].getAddress().getState(),array[i].getPolicy().getType(),array[i].calculateBill());
    			
    			}
    			
    			message+=String.format("Total Premium Due          $%-50.2f\n",total);
    		
    			return message;
    	}
    
    }

Similar Threads

  1. compile error - calling methods from main
    By counterfox in forum New To Java
    Replies: 1
    Last Post: 04-16-2010, 05:00 PM
  2. Calling for methods
    By soccer_kid_6 in forum New To Java
    Replies: 3
    Last Post: 02-27-2010, 09:12 PM
  3. Calling Methods
    By bluegreen7hi in forum New To Java
    Replies: 3
    Last Post: 12-17-2007, 06:22 AM
  4. calling array from main
    By nalinda in forum New To Java
    Replies: 1
    Last Post: 11-17-2007, 09:41 PM
  5. need help calling methods
    By lowpro in forum New To Java
    Replies: 2
    Last Post: 11-15-2007, 09:53 AM

Posting Permissions

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