Results 1 to 3 of 3

Thread: Java Methods Help!

  1. #1 Java Methods Help! 
    New Member
    Join Date
    Mar 2013
    My program is supposed to calculate the squares of the numbers from 1 to twelve, then display them in a chart for showing the number and their square. I am supposed to use two methods but i'm having trouble how. Please help and tell me what is wrong


    public class findingSquares
    public static void main (String [] args) throws IOException

    System.out.println("Number " + "Square");

    findSquare root = new findSquare();

    int numSquare = root.square();

    int num = 0;

    while (num >= 0 && num <= 11)
    System.out.println(num + "\t" + numSquare);

    public static int findSquare (String square)
    int num = 1;
    int numSquare = num * num;

    return numSquare;

    Reply With Quote  


  3. #2  
    Forum Freshman
    Join Date
    Oct 2010
    First of all format your code properly. Use idents and coding style.

    Second, get a normal IDE. IntelliJ IDEA CE, Eclipse or NetBeans etc. will be fine. This will solve half of your problems.

    For some strange reason you are instatinating findingSquares, which is typed as "findingSquare" and calling a method square() which is not defined.

    The last thing, learn about variable visibility area.

    Reply With Quote  

  4. #3  
    has lost interest seagypsy's Avatar
    Join Date
    Nov 2012
    I agree with BlasW. Java, like any other language is very particular about spelling and syntax. You may find it easier to post code in proper format if you use the code tags available.use this [code]put your code in here[/code] to get this :
    put your code in here
    If this is for coursework and your instructor doesn't allow you to use an ide (i had one that insisted we use nothing but notepad and the latest jdk and jre) you can use notepad++ and it will color code some elements of your code. just set the language to java. This will help some. using an ide creates files that are not necessary if you are simply going to run the program from cmd prompt.

    This is what notepad++ looks like:
    Speaking badly about people after they are gone and jumping on the bash the band wagon must do very well for a low self-esteem.
    Reply With Quote  

Similar Threads

  1. Java Methods Help!
    By samanthaxc in forum General Discussion
    Replies: 1
    Last Post: March 11th, 2013, 02:51 PM
  2. Methods for Archaeological Dating
    By Arcane_Mathematician in forum History
    Replies: 17
    Last Post: May 23rd, 2009, 08:43 PM
  3. Methods for EPS extraction
    By mia-kaimonadiki in forum Chemistry
    Replies: 2
    Last Post: September 5th, 2008, 03:25 AM
  4. Evolutionary Science Methods
    By Ajain in forum Biology
    Replies: 1
    Last Post: July 12th, 2007, 09:58 PM
  5. Methods: How to reduce a categorization
    By Jacq in forum Behavior and Psychology
    Replies: 0
    Last Post: September 7th, 2006, 07:04 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