Help wanted with JAVA - Sajha Mobile
SAJHA MOBILE
Help wanted with JAVA
Posts 11 · Viewed 6682 · Go to Last Post
jerrybhoot
· Snapshot
Like · Likedby · 0
Guys can you help me write this program. Thanx in advance. I want to thank you again tech guy.
jerrybhoot

 a Java application that prints the following table using the sqrt ( ) method in the Math class using a for loop to produce the output results.

Number    SquareRoot
0    0.0000
2    1.4142
4    2.0000
6    2.4495
8    2.8284
10    3.1623
12    3.4641
14    3.7417
16    4.0000
18    4.2426
20    4.4721

divdude
· Snapshot
Like · Liked by · 0
Piggyback ride is not always a viable alternative.
In other words if you cant be bothered to do that on your own
dont bother with java or any form of programming.
rastrapati
· Snapshot
Like · Liked by · 0

You seems to be very begineer in java. Try to research on internet before asking anyone for help. 
It's too simple problem. Anyway here's simple for loop that will generate table upto 100.

for(int i=0;i<100;i+=2){
 System.out.println(i+"\t\t"+Math.sqrt(i));
}

rastrapati
· Snapshot
Like · Liked by · 0

 

Last edited: 06-Oct-08 07:20 PM
khai_k_khai_k
· Snapshot
Like · Liked by · 0
/* Use System.out.format to maintain the precision of the double value */
/* Try to read books like Core Java Vol 1, if u are a beginner. */

public class SquareRoot {
    public static void main(String[] args) {
        System.out.println("Number \t SquareRoot");
        for (int i = 0; i <= 20; i = i + 2) {
            System.out.format("%d \t %1.4f \n", i, Math.sqrt(i));
        }
    }
}

/* Output */
/*
Number      SquareRoot
0      0.0000
2      1.4142
4      2.0000
6      2.4495
8      2.8284
10      3.1623
12      3.4641
14      3.7417
16      4.0000
18      4.2426
20      4.4721
*/

khai_k_khai_k
· Snapshot
Like · Liked by · 0
/* Use System.out.format to maintain the precision of the double value */
/* Try to read books like Core Java Vol 1, if u are a beginner. */

public class SquareRoot {
    public static void main(String[] args) {
        System.out.println("Number \t SquareRoot");
        for (int i = 0; i <= 20; i = i + 2) {
            System.out.format("%d \t %1.4f \n", i, Math.sqrt(i));
        }
    }
}

/* Output */
/*
Number      SquareRoot
0      0.0000
2      1.4142
4      2.0000
6      2.4495
8      2.8284
10      3.1623
12      3.4641
14      3.7417
16      4.0000
18      4.2426
20      4.4721
*/

yellow
· Snapshot
Like · Liked by · 0
I hope Jerry bhoot has enough help with " khai k khai k" 's solution.

Don't forget to remove the */ and /* Coz I know you are going to copy the whole damn thing and say it does not work. I agree with divdude, abt piggyback thing.
yellow
· Snapshot
Like · Liked by · 0
I hope Jerry bhoot has enough help with " khai k khai k" 's solution.

Don't forget to remove the */ and /* Coz I know you are going to copy the whole damn thing and say it does not work. I agree with divdude, abt piggyback thing.
yellow
· Snapshot
Like · Liked by · 0
I hope Jerry bhoot has enough help with " khai k khai k" 's solution.

Don't forget to remove the */ and /* Coz I know you are going to copy the whole damn thing and say it does not work. I agree with divdude, abt piggyback thing.
rawbee
· Snapshot
Like · Liked by · 0

i think its not a good way to  post someone's school homework in sajha. this will discourage to student doing hardwrok. i dont meant to say dont help at all but instead to giving a whole program code, you guys can just post pseudocode for program or just give a concept.

thanks anyway. we are really great to have  a programmers like you.

Rusty
· Snapshot
Like · Liked by · 0

I think the original author is vanished. I hope he has not dropped the Java class yet. Only suggestions I have to you is: READ THE BOOK AND LISTEN CLASS LECTURES CAREFULLY before you go out there, seeking for help. 

First, recognize what you need to know to solve the excercise you're given.  You already got the solution; however, if you look at your exercise carefully, you know that it needs some lessons on basic Java class syntax, different types of LOOP in Java, and use of math function library. Very simple! Not a rocket science. So, open your book and read it.

If you don't know fundamentals of programming language, then read the book again from the beginning. Know how a program is created, complied, and executed. Try to take advantage of debugger that comes with the editor you use. Don’t give up just because you get some discouraging comments from some people.  Call it a quit only when your heart tells you to quit.  

 

Please log in to reply to this post

You can also log in using your Facebook
View in Desktop
What people are reading
You might like these other discussions...
· Posts 16 · Viewed 2496
· Posts 4 · Viewed 873
· Posts 3 · Viewed 258
· Posts 20 · Viewed 3125 · Likes 1
· Posts 36 · Viewed 4210 · Likes 9
· Posts 2 · Viewed 215
· Posts 105 · Viewed 24801 · Likes 26
· Posts 1 · Viewed 97
· Posts 24 · Viewed 3164
· Posts 1 · Viewed 117



Travel Partners
Travel House Nepal