Results 1 to 4 of 4
  1. #1
    nidhigarg06 is offline Member
    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    0

    Default methods: no error: output=0.0

    class Circle
    {
    static final float PI=3.1415f;
    float puCost;
    float area;
    float radius;

    float area()
    {
    return PI*radius*radius;
    }

    float calCost()
    {
    float cost=puCost*area;
    return cost;
    }
    }
    class circle2
    {

    public static void main(String args[])
    {
    Circle circle=new Circle();
    circle.puCost=100;
    circle.radius=3;

    float area=circle.calCost();
    System.out.println(area);
    }
    }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default Re: methods: no error: output=0.0

    You should step through this with a debugger, or at least add some print statements, to figure out exactly where the program's execution differs from your expectation.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: methods: no error: output=0.0

    Adding to Kev's reply.
    That's what you get when using ambiguos method and attribute names. The compiler doesn't have a crystal ball, like we have.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  4. #4
    nidhigarg06 is offline Member
    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    0

    Default Re: methods: no error: output=0.0

    Hi,
    Here i have used 2 methods (nested).
    I did not want to call them in main method, but call only one of them and get the output.
    but it seems i much call both of them.
    Is there a way out to call one method only and get the desired output.

Similar Threads

  1. output error
    By mentoes178 in forum New To Java
    Replies: 1
    Last Post: 06-17-2013, 07:39 PM
  2. Error output
    By Kartright in forum New To Java
    Replies: 5
    Last Post: 05-30-2013, 05:28 AM
  3. Replies: 11
    Last Post: 06-28-2011, 12:47 AM
  4. output giving null, methods not reading properly
    By csuever in forum New To Java
    Replies: 22
    Last Post: 04-01-2011, 02:13 AM
  5. design? return output within methods
    By jon80 in forum New To Java
    Replies: 1
    Last Post: 06-08-2009, 07:22 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
  •