-
September 5th, 2010, 07:49 PM
#1
Need help with a basic java program
Alright.. well i'm kind of stuck with a basic java program. Basically what i have to do is create a simple program where you put your earth age and the output would be your age on Mercury, Venus, Jupiter, and Saturn.
The formula i have to use is y = (x*365)/d
Where y is the age on the planet, x is your earth age, and d is the number of earth days it takes for the planet to travel around the sun.
Planet d= approx number of earth days for this planet to travel around the sun
Mercury 88
Venus 225
Jupiter 4380
Saturn 10767
I'm kind of stuck on this.. this is all i have so far
import java.util.*;
import java.io.*;
public class Program1
{
its not much at all.. i have no clue what to do next... any advice or help? Thank you.
-
September 6th, 2010, 06:29 AM
#2
Re: Need help with a basic java program
You need four variables to hold the day values for the planets, and you need a method that requests Earth age from the user and prints out the results of the formula for each of the planet day values.
We can't teach Java here, but we'll try to help people who make an effort and get stuck on something. You should be able to write simple Java programs, and if you can't, there are plenty of tutorials out there you can learn from. For example The Java Tutorials.
If you ask more specific questions, you'll get more specific answers, but don't expect people to write the code for you.
Learning how to learn is life's most important skill...
T. Buzan
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
September 6th, 2010, 08:13 AM
#3
Re: Need help with a basic java program
Try tis code for ur plm...
public class Main {
public double comput(long x,long d)
{
double v= (x*365)/d;
return v;
}
public static void main(String[] args) {
long m= 88;
long v =225;
long j=4380;
long s=10767;
Main a=new Main();
System.out.println("age of m is "+a.comput(200000,m));
}
}
u can also use args[0] and args[1] values. for user input
-
September 6th, 2010, 02:49 PM
#4
Re: Need help with a basic java program
Try tis code for ur plm...
Please don't use text speak. Many of the members here are not native English speakers and won't understand this. I am a native English speaker and I don't know for sure what 'ur plm' means (your problem?).
Also please don't just provide a chunk of code when people ask for help. Any of us can write such a simple bit of code and in less time than we take in helping people solve things for themselves but just providing code doesn't teach them anything.
Finally, if you are going to write code make sure it does what it's supposed to (or document where it differs from the request) and please post it in code tags
-
September 18th, 2010, 01:59 PM
#5
Re: Need help with a basic java program
always remember to close curly brackets too, and your program will need a "starting" method. Regardless of how clueless you are, your code should have looked like this
import java.util.*;
import java.io.*;
public class Program1
{
public static void main(String[] args){
// insert code you learn from tutorials given here
}
}
here's an amazing tutorial i used to teach myself java http://math.hws.edu/javanotes/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|