-
[SOLVED] Radio Buttons
:confused:
I have completed a project using radio buttons that runs fine using the following script
Code:
double inch = 0;
double kg;
double lbs = 0;
double cm;
double outputInches;
double outputLbs = 0;
boolean ok;
ok = true;
String outinch;
String outlbs;
// try catch for numeric data only
try {
cm = Double.parseDouble(txtCm.getText());//expect any numerical input
}
catch (NumberFormatException n) {//to catch none numeric input
Optpane.showMessageDialog(this,"Enter numbers only please",
"please re-enter",Optpane.ERROR_MESSAGE); // Optpane kicks in on error
ok = false; //boolean to trigger Optpane on alpha entry
}
// start of formula to convert cm to inches and inches to cm - uses class file Units.java
cm=Double.parseDouble(txtCm.getText());
outputInches = RbMetric.RadioButtExercise(cm,inch);
// Class.PackageName
txtInch.setText(outinch=conversions.format(outputInches));
// End of formula
So my way of thinking says that apart from the variables and package names everything should work in whatever package.
However the following code gives me an error, 'Cannot find symbol, Symbol:Method Bmi31(Double,Double), Location Class bmi31.MetricCm.bmi31, Required Double, Variable inches might not have been initialized.'
Code:
double inchs = 0;
double cms;
double outputInches;
boolean ok;
ok = true;
String outinch;
// try catch for numeric data only
try {
cms = Double.parseDouble(txtHeight.getText());//expect any numerical input
}
catch (NumberFormatException n) {//to catch none numeric input
optPane1.showMessageDialog(this,"Enter numbers only please",
"please re-enter",optPane1.ERROR_MESSAGE); // Optpane kicks in on error
ok = false; //boolean to trigger Optpane on alpha entry
}
// start of formula to convert cm to inches and inches to cm - uses class file Units.java
cms=Double.parseDouble(txtHeight.getText());
outputInches = MetricCm.bmi31(cms,inchs);
// Class.PackageName
txtConvHeight.setText(outinch=bodymass.format(outputInches));
// End of formula
I ran the clean build then the initialise error disappeared but the rest is still there, I do not understand why it is telling me i need a double for the class that contains the formula, the program that works does not have it.
Can someone advise me what the problem is please
Thanks in advance.
-
Does the MetricCm class have a static method bmi31? If so, perhaps you want to show it to us.
I don't see a variable called "inches" though.
-
Thanks, I was kind of missing a big chucnk of code for what I wanted just didnt notice......
:D