running into 'incompatible error' message and casting will not solve
This is frustrating. If I cast, the error message 'incompatible error'
is replaced with another error message 'inconvertible error.' With just
using two class files, I am trying to learn how to do a formula in a
method file, then transfer the input into a variable within the main
class file. In the below coding, I am trying to figure out how to place
an object's data into a variable (or, as an alternative,
System.out.print the object data, but I run into errors when doing
that). Matter of fact, if I do not figure out this technique, I will
not be able to fully complete my school assignment. All 4 books I have
didn't even get me this far. Half of this stuff was trial an error.
Anyways, here is the coding from both files. Thank you for the help.
---CODING FOR MAIN CLASS FILE---
import java.io.*;
public class MainClass {
public static void main(String[] args) throws IOException {
//declare variables
double jDouble = 0;
BufferedReader dataIn = new BufferedReader(new
InputStreamReader(System.in));
//object creation for input method
InputMethod input = new InputMethod();
jDouble = input.myInput();
System.out.println(jDouble);
}
}
---CODING FOR THE METHOD FILE---
import java.io.*;
public class InputMethod {
String i;
double iDouble;
BufferedReader dataIn = new BufferedReader(new
InputStreamReader(System.in));
//basic input method which converts a string into a
double
public void myInput() throws IOException {
System.out.print("Enter some data: ");
i = dataIn.readLine();
iDouble = Double.parseDouble(i);
}
}