Zap Brannigan
Golden Member
So I'm prgramming for the first time and have hit a slight bump in the road. I have this error popping up,
Class product is public, should be declared a file named Product.java. It's on line 5. Here is what I have so far and am trying ot figure out how to fix this so that it will compile.
// Ex.2.5: Product.java
// Calculate the product of three integers.
import java.util.Scanner; // program uses Scanner
public class Product <------this is line 5
{
public static void main( String args[] )
{
// create Scanner to obtain input from command window
Scanner input = new Scanner ( System.in );
int x; // 10
int y; // 20
int z; // 30
int result; // product of numbers
System.out.print("10:"); // prompt for input
x = input.nextInt(); // read first integer
System.out.print("20:"); // prompt for input
y = input.nextInt(); // read second integer
System.out.print("30;"); // prompt for input
z = input.nextInt(); //read third integer
result = x * y * z; // calculate product of numbers
System.out.printf( "product is %d\n", result);
} // end method main
} // end class Product
Class product is public, should be declared a file named Product.java. It's on line 5. Here is what I have so far and am trying ot figure out how to fix this so that it will compile.
// Ex.2.5: Product.java
// Calculate the product of three integers.
import java.util.Scanner; // program uses Scanner
public class Product <------this is line 5
{
public static void main( String args[] )
{
// create Scanner to obtain input from command window
Scanner input = new Scanner ( System.in );
int x; // 10
int y; // 20
int z; // 30
int result; // product of numbers
System.out.print("10:"); // prompt for input
x = input.nextInt(); // read first integer
System.out.print("20:"); // prompt for input
y = input.nextInt(); // read second integer
System.out.print("30;"); // prompt for input
z = input.nextInt(); //read third integer
result = x * y * z; // calculate product of numbers
System.out.printf( "product is %d\n", result);
} // end method main
} // end class Product