Board index » jbuilder » 3rd class doesn't see 1st and 2nd

3rd class doesn't see 1st and 2nd


2004-08-28 04:17:44 AM
jbuilder19
I put theese two java files in a directory:
public class ComputeArea
{
public static void main(String[] args)
{
double area;
double depth;
double gals;
final double cipg = 231;
double side;
System.out.print("For equal 24sided hexagon tank only \n");
System.out.print("Enter depth ");
depth = MyInput.readDouble();
System.out.print("\n");
System.out.print("Enter length of side ");
side = MyInput.readDouble();
area = (side*side)*2.7207;
System.out.println("Area is " + area );
gals = area * depth / cipg;
System.out.println("Holds " + gals + " gallons " );
}
}
And:
import java.io.*;
public class MyInput
{
// Read a string from the keyboard
public static String readString()
{
BufferedReader br
= new BufferedReader(new InputStreamReader(System.in), 1);
// Declare and initialize the string
String string = "";
// Get the string from the keyboard
try
{
string = br.readLine();
}
catch (IOException ex)
{
System.out.println(ex);
}
// Return the string obtained from the keyboard
return string;
}
// Read an int value from the keyboard
public static int readInt()
{
return Integer.parseInt(readString());
}
// Read a double value from the keyboard
public static double readDouble()
{
return Double.parseDouble(readString());
}
// Read a byte value from the keyboard
public static byte readByte()
{
return Byte.parseByte(readString());
}
// Read a short value from the keyboard
public static short readShort()
{
return Short.parseShort(readString());
}
// Read a long value from the keyboard
public static long readLong()
{
return Long.parseLong(readString());
}
// Read a float value from the keyboard
public static float readFloat()
{
return Float.parseFloat(readString());
}
}
They work !!!
BUT ????
When I add:
public class circle
{
double radius;
public circle()
{
}
radius = MyInput.readDouble();
System.out.println("Holds ");
}
It does:
<identifier>expected at ...
 
 

Re:3rd class doesn't see 1st and 2nd

johndumas wrote:
Quote
BUT ????

When I add:

public class circle
{
double radius;

public circle()
{
}

radius = MyInput.readDouble();
System.out.println("Holds ");

}

It does:

<identifier>expected at ...
put those two lines of code inside your (missing) public static main method.
--
Regards,
Lori Olson [TeamB]
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
www.google.ca/advanced_group_search
Other Newsgroup Searches:
www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
www.visi.com/~gyles19/fom-serve/cache/1.html