Results 1 to 6 of 6
  1. #1
    Denis2k11 is offline Member
    Join Date
    Oct 2012
    Posts
    35
    Rep Power
    0

    Default What's wrong with my code/ :-/

    I keep trying to program a code to count the 6 digits of a si-digit number but I keep getting a (cannot find symbol) error. Can someone point out were I am going wrong?
    Java Code:
    import java.util.Scanner;
    public class Integer
    {
    	public static void main(String[]args)
    	{
    		int Number;
    		Scanner console = new Scanner (System.in);
    		System.out.print("Enter six-figure digit: ");
    		Number = Integer.parseInt(console.nextLine());
    		int Result;
    		Result = (Number /100000);
    		Result = Result + ((Number % 100000) / 10000);
    		Result = Result + ((Number / 1000));
    		Result = Result + ((Number % 1000) / 100);
    		Result = Result + (Number / 10);
    		Result = Result + ((Number % 10) / 1);
    		System.out.print("The sum of the six-figure digit is: " + Result);
    	}
    }
    Last edited by Tolls; 10-11-2012 at 05:45 PM.

  2. #2
    wdh321 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    116
    Rep Power
    0

    Default Re: What's wrong with my code/ :-/

    You have named your scanner "console", but you do not use it anywhere.
    http://docs.oracle.com/javase/1.5.0/...l/Scanner.html

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,183
    Rep Power
    20

    Default Re: What's wrong with my code/ :-/

    Please give us the full error and where it occurs.
    (I've corrected your close code tag typo)

    Note that console is used in this line:
    Java Code:
    Number = Integer.parseInt(console.nextLine());
    and even if it wasn't that would not generate a "cannot find symbol" compiler error.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    wdh321 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    116
    Rep Power
    0

    Default Re: What's wrong with my code/ :-/

    Quote Originally Posted by Tolls View Post
    Please give us the full error and where it occurs.
    (I've corrected your close code tag typo)

    Note that console is used in this line:
    Java Code:
    Number = Integer.parseInt(console.nextLine());
    and even if it wasn't that would not generate a "cannot find symbol" compiler error.
    What is there now is different to what was originally posted, where in.nextLine() was used.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,183
    Rep Power
    20

    Default Re: What's wrong with my code/ :-/

    Oh right, but not using a variable will not give a "cannot find symbol" compiler error, so unless something else has been edited then that won't be the problem.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    GerD is offline Member
    Join Date
    Oct 2012
    Posts
    11
    Rep Power
    0

    Default Re: What's wrong with my code/ :-/

    Hello there I am new to Java and have been getting some help but I cant figure out why I am getting errors please help




    import java.util.Scanner;

    class VegetablesLab
    {
    public static void main( String[] args )
    {
    int apples = 30;
    int oranges = 45;
    int turnips = 70;

    double strawberries = 2.30;
    double potatoes = 3.25;
    double carrots = 1.25;

    String name = "";
    String address = "";
    String ccnum ="";
    String dob = "";
    String email = "";
    String email2 = "";
    String grocery1 = "";
    String grocery2 = "";
    String grocery3 = "";
    String amount1 = "";
    String amount2 = "";
    String amount3 = "";
    Scanner input = new Scanner( System.in );

    System.out.println( "Enter your Full Name Please:" );
    name = input.nextLine();
    System.out.println( name );


    System.out.println("Enter your Address please");
    address = input.nextLine();
    System.out.println( address );

    System.out.println("Enter your Credit Card number please:");
    ccnum = input.nextLine();
    System.out.println( ccnum );

    System.out.println("Enter your dob:");
    dob = input.nextLine();
    System.out.println( dob );

    System.out.println("Enter your email address:");
    email = input.nextLine();
    System.out.println( email );

    System.out.println("Re-enter your email address:");
    email2 = input.nextLine();
    System.out.println( email2 );

    if( email == email2)


    System.out.println("Enter first grocery item:");
    amount1();
    grocery1 = input.nextLine();
    System.out.println(firstgrocery);


    System.out.println("Enter second grocery item:");
    amount2();
    grocery2 = input.nextLine();
    System.out.println(secondgrocery);



    System.out.println("Enter third grocery item:");
    amount3();
    grocery3 = input.nextLine();
    System.out.println(thirdgrocery);

    System.out.println("Total cost");

    }
    }

Similar Threads

  1. What is wrong with my code?
    By tweetychirpy in forum Threads and Synchronization
    Replies: 4
    Last Post: 12-23-2011, 06:16 PM
  2. What's wrong with my code?
    By Johanis in forum New To Java
    Replies: 1
    Last Post: 10-30-2011, 01:38 PM
  3. What is wrong with my code?!
    By new2java2009 in forum New To Java
    Replies: 2
    Last Post: 04-17-2010, 09:01 PM
  4. pls tell wat wrong with my code???
    By low224 in forum New To Java
    Replies: 13
    Last Post: 01-11-2009, 08:40 AM
  5. what is wrong with this code
    By masaka in forum New To Java
    Replies: 5
    Last Post: 04-16-2008, 09:27 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
  •