Results 1 to 3 of 3
  1. #1
    shandog1079 is offline Member
    Join Date
    Mar 2011
    Posts
    2
    Rep Power
    0

    Exclamation cannot find symbol: method Scanner(java.io.InputStream)

    G'day everyone

    I am just beginning a university course in programming and I previously have no experience with it. It's only an introduction course so not difficult to pick up, however I am having a problem compiling a simple program designed to calculate the area and perimeter of a rectangle after receiving input from the user (height and length values).

    The error my IDE (TextPad) is providing is:

    C:\Users\Shannon\Documents\ADFA\Programming\Assign ment Two\rectangle.java:22: cannot find symbol
    symbol : method Scanner(java.io.InputStream)
    location: class rectangle
    Scanner input = Scanner(System.in);
    ^
    1 error

    Tool completed with exit code 1

    This is the code I have written:

    //************************************************** ***************************
    // rectangle.java Author Shannon Emanuel
    //
    // Calculates the area and perimeter of a rectangle
    // where area=width*height and perimeter=2*(width+height)
    //
    //************************************************** ***************************
    import java.util.Scanner;

    public class rectangle
    {

    public static void main (String[] args)

    {
    int width;
    int height;
    int area;
    int perimeter;

    //Obtaining the parameters for calculations
    Scanner input = Scanner(System.in);
    System.out.print ("Please enter the horizontal width:"); //obtains width
    width = input.nextInt();
    System.out.print ("Please enter the vertical height:"); //obtains height
    height = input.nextInt();

    //Performing the calculations
    area = width*height;
    perimeter = 2*(width+height);

    //Output of the answers
    System.out.println ("The area of the rectangle is " + area);
    System.out.print ("The perimeter of the rectangle is " +perimeter);
    }
    }



    If anyone could help me figure out what I am doing wrong I would really appreciate the help.

    Thanks!

    Shannon

  2. #2
    tabchas's Avatar
    tabchas is offline Member
    Join Date
    Mar 2011
    Location
    Austin
    Posts
    60
    Rep Power
    0

    Default

    Read this: Creating Objects

    The problem is where you write: "Scanner input = Scanner(System.in);" it should be "Scanner input = new Scanner(System.in);

    Read the link for more information.

  3. #3
    shandog1079 is offline Member
    Join Date
    Mar 2011
    Posts
    2
    Rep Power
    0

    Default

    WOW

    I cant believe I missed that....

    Thanks for your help!

Similar Threads

  1. Replies: 2
    Last Post: 03-08-2011, 04:08 PM
  2. HELP! can't find symbol-method
    By Jack9333 in forum New To Java
    Replies: 2
    Last Post: 03-04-2011, 02:48 AM
  3. Replies: 10
    Last Post: 12-22-2010, 02:12 AM
  4. cannot find symbol - method iterator()
    By D.Calladine in forum New To Java
    Replies: 1
    Last Post: 11-30-2010, 01:13 PM
  5. Replies: 8
    Last Post: 10-17-2010, 11:24 AM

Posting Permissions

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