Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2013
    Thanked 0 Times in 0 Posts

    Question Simple JAVA code help

    I am new to this, and have wrote the code, but keep getting the same error and completely clueless on what to do next. Any help would be greatly appreciated.

    import java.util.*;
    public class A1RE5161843 {
    public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    System.out.print("Enter length of rectangle :");
    double length = input.nextDouble();

    System.out.print("Enter width of rectangle :");
    double width = input.nextDouble();

    System.out.println("Area: "+(length * width));
    System.out.println("Perimeter: "+((2*length)+(2*width)));


    Main.java:12: class A1RE5161843 is public, should be declared in a file named A1RE5161843.java
    public class A1RE5161843 {
    1 error

  2. #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,668 Times in 2,637 Posts
    The code compiles and runs fine. It looks like you don't have the correct file name in use, or that you're not running the javac properly if manually doing it from the command line.
    Did you use an IDE for this, or did you just create a text file? Check the directory for this, and see what the extension is (it has to be .java).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts