Hello: Names Red, wanting to get java tips aka teaching an old dog new tricks. Hobbies are carbon bikes, biodiesel, remodeling the moneypit. Grandkids are the prio though, breaking in my 5 year old grandson to be my wingman when I hit the trails on the bike, the granddaughter will get the pull behind rickshaw ride and be my spring weight training regimen. Well thanks for entertaining any newbie questions.

Recommended Answers

All 5 Replies

Hi Red...Welcome to Daniweb Friend :)

welcome

Glad to have you with us!

Thanks much, when I posted last night I was very tired and painted into a corner. I got my program to compile with output today and now my only issue is look of the output. IF you have any pointers on how to control println or how to tweak printf with the math.sqrt invovled, that would be great. Heres what I have that works and I commented out my failed attempt at printf.

public class SqrtPgm {

    /**
     * @param args
     */
    public static void main(String[] args) {

        int MAX_NUMBER = 20;
        // Display table headings
        System.out.println("Number SquareRoot");

        /** Do some math, see if even then 
         *  return the square root of a given integer
         *  until maxxed out */

        for (int i = 0; i <=MAX_NUMBER; i += 2)
        System.out.println( i + "    "+ Math.sqrt(i));
        //System.out.printf("%-8d + Math.sqrt%-7d\n(i");



    }


}

Thanks for the support, I think this site is going to be a real help in learning this language.

apparently the post compresses some spaces, I had the println with more spaces in between the quotes to force the second field to justify better. It should create output starting with 0 flush left under Number and follow with the sqrt under Square Root but with a jagged output with too much output to the right of the decimal place.

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.