Results 1 to 4 of 4
  1. #1
    dest is offline Member
    Join Date
    Apr 2012
    Posts
    1
    Rep Power
    0

    Default Cannot find symbol

    I working on a program right now, but i'm stuck with this error. if anyone would be kind enough to help, it would be great.
    Java Code:
    import java.util.*;
       public class Shapes {
          public static void main (String[] args){
          
             Scanner sc = new Scanner (System.in);
          	
             int input=0,line,repeatnum;
             char repeat;
             do {
                System.out.println ("Welcome to the Shape Generator:");
                System.out.println (" ");			
                System.out.println ("This program draws the following shapes:");
                System.out.println ("1) Horizontal Line");
                System.out.println ("2) Vertical Line");
                System.out.println ("3) Rectangle");
                System.out.println ("4) Left slant right angle triangle");
                System.out.println ("4) Isosceles triangle");
                System.out.println ("5) grapefruit, bacon, eggs, coffee");
                System.out.print ("Enter your choice (1-5): ");
                input=sc.nextInt();
             
                while (input<=0 || input>=6){
                   if (input<=0 || input>=6){
                      System.out.println ("Invalid choice!  Your choice must be between 1 and 5.");
                      System.out.print ("Enter your choice (1-5): ");
                      input=sc.nextInt();
                   }      
                }
                if (input==1){
                   System.out.print ("Enter the length of the horizontal line (1-20):  ");
                   line = sc.nextInt();
                	
                   while (line<=0 || line>=20){
                      if (line<=0 || line>=20){
                         System.out.println ("Invalid dimension!  The dimension must be between 1 and 20.");
                         System.out.print ("Enter the length of the horizontal line (1-20): ");
                         line=sc.nextInt();
                      }      
                   }
                	
                   System.out.println ("Here is the horizontal line: ");
                   System.out.println (" ");
                	
                   for (int i =0;i<line;i++){
                      System.out.print ("*");
                   }
                	     	
                   System.out.print ("Would you like to draw another one (y/n)?");
                   repeat=sc.nextLine.atChar(0);
                
                   while (repeat!='y' || repeat!='Y' || repeat!='n' || repeat!='N'){	
                      if (repeat!='y' || repeat!='Y' || repeat!='n' || repeat!='N'){
                         System.out.println ("Invalid input!  Your input must be 'y' or 'n'.");
                         System.out.print ("Would you like to draw another one (y/n)?");
                         repeat=sc.nextLine.atChar (0);
                      }
                   }
                } 
             } while (repeat=='n' || repeat=='N');                                          
          }
       }
    whenever i try to compile, the error is

    Java Code:
     ----jGRASP exec: javac -g Shapes.java
    
    Shapes.java:54: cannot find symbol
    symbol  : variable nextLine
    location: class java.util.Scanner
                   repeat=sc.nextLine.atChar(0);
                            ^
    Shapes.java:60: cannot find symbol
    symbol  : variable nextLine
    location: class java.util.Scanner
                         repeat=sc.nextLine.atChar (0);
                                  ^
    2 errors
    
     ----jGRASP wedge2: exit code for process is 1.
     ----jGRASP: operation complete.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,789
    Rep Power
    25

    Default Re: Cannot find symbol

    You have coded nextLine like a field, not like a method. Method calls have ()s
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Bestsanchez is offline Member
    Join Date
    Jan 2012
    Location
    The Coffee Pot
    Posts
    36
    Rep Power
    0

    Default Re: Cannot find symbol

    And i'm pretty sure the String method atChar() doesn't exist

  4. #4
    jwolf is offline Member
    Join Date
    Jan 2012
    Location
    Minnesota
    Posts
    4
    Rep Power
    0

    Default Re: Cannot find symbol

    There is a String method that does the same thing,
    string.charAt(int);

Similar Threads

  1. Still cannot find symbol!
    By Johanis in forum New To Java
    Replies: 1
    Last Post: 11-04-2010, 05:32 PM
  2. Can not find symbol ???
    By AliceNewbie in forum New To Java
    Replies: 1
    Last Post: 02-17-2010, 02:44 AM
  3. cannot find symbol
    By GabWit in forum New To Java
    Replies: 3
    Last Post: 01-25-2009, 01:13 AM
  4. Replies: 9
    Last Post: 10-18-2008, 09:26 PM
  5. Replies: 3
    Last Post: 05-01-2008, 09:30 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
  •