Help with code!

Can anyone help me fix this code. Yes it has to be in this format (method). Of course the simple way would to put it all under main. But I need it like this or close to.

import javax.swing.*;

public class Ola2

{

public static void main (String [] args)

{

Ola2 One_Rep = new Ola2();

System.out.println(One_Rep.My_Input());

}

public static void One_Rep()

{

double weight, reps, One_Rep;

}

public static double My_Input()

{

String My_Input;

double weight;

My_Input = JOptionPane.showInputDialog( "Enter weight lifted." );

weight = Double.parseDouble( My_Input );

double reps;

My_Input = JOptionPane.showInputDialog( "Enter # of reps lifted." );

reps = Double.parseDouble( My_Input );

double One_Rep = (Math.round(weight / (1.0278 - (.0278 * reps))));

JOptionPane.showInputDialog( null, "Your one rep max is: " + One_Rep );

}

}

[985 byte] By [deanwata] at [2007-11-26 22:27:42]
# 1
Obviously it won't compile, how about you (a) read the compiler's messages to you and (b) learn how to declare variables in Java.
itchyscratchya at 2007-7-10 11:30:22 > top of Java-index,Desktop,Core GUI APIs...
# 2
I have read the compiler yes your right it won,t compile. I am new to this and I,m sure that you are right about my variables. Thats why I have posted to get help.
deanwata at 2007-7-10 11:30:22 > top of Java-index,Desktop,Core GUI APIs...
# 3
Also learn [url= http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html]Java Coding Conventions[/url].
ignignokt84a at 2007-7-10 11:30:22 > top of Java-index,Desktop,Core GUI APIs...
# 4
> Thats why I have posted to get help. http://faq.javaranch.com/view?TellTheDetails
Michael_Dunna at 2007-7-10 11:30:22 > top of Java-index,Desktop,Core GUI APIs...
# 5

Well, if your are using Windows you could just try typing

Ctrl-A, Delete

and that would fix your code. ;)

or you could try solving the problem described by the compilation error. I'm guessing something related to method should return type double. So return a double. Add

return One_Rep;

to the end of the My_Input method.

If there is something else wrong with the code (that you want fixed), please let us know.

pthorsona at 2007-7-10 11:30:22 > top of Java-index,Desktop,Core GUI APIs...
# 6

you could just try typing Ctrl-A, Delete

LOL!

@OP: Your "One_Rep()" method should be removed and you should declare "reps" within your "My_Input()" method. You also need to return a double from that method.

You seem to be quite confised as to the difference between variables and methods.

And yes, do try and use Java conventions.

itchyscratchya at 2007-7-10 11:30:22 > top of Java-index,Desktop,Core GUI APIs...