Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: My code is not working (method)

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default My code is not working (method)

     import java.util.Scanner;
     
    public class Number { 
    	private int numberEntered;
     private int firstDigit;
    private int secondDigit;
    private int thirdDigit;
    private int fourthDigit;
    private int fifthDigit;
     
     
    	public static void main(String[] args) {
     
     
     
     
    }
     
    	public void getNumberFromUser (){
     
    		Scanner input = new Scanner (System.in);
    		System.out.print ("\nEnter a five digit number: ");
    		numberEntered = input.nextInt();
     
    		while (numberEntered<10000 || numberEntered>99999)
    		{System.out.print ("\nYou input the wrong amount of digits. Please enter 5 digit number: ");
    		numberEntered = input.nextInt();}
    		}
     
     
    	public void displayDigits(){System.out.printf ("The number is\n");
    	System.out.printf ("%d\n" , numberEntered / 10000);//if you take just one zeroes from it you wont get the answer
    	System.out.printf ("%d\n" , numberEntered % 10000 / 1000);
    	System.out.printf ("%d\n" , numberEntered % 10000 % 1000 / 100);
    	System.out.printf ("%d\n" , numberEntered % 10000 % 1000 % 100 / 10);  
    	System.out.printf ("%d\n" , numberEntered % 10000 % 1000 % 100 % 10 / 1);
     
    	}
    }//end of class



    Its not working, and its not letting me input the number.. can someone help me about this


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: My code is not working (method)

    You are going to have to be a lot more specific than "it's not working". What happens when you step through this with a debugger? What happens when you add some print statements? Where does the program stop working?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: My code is not working (method)

    kevin is right, but i would start by putting some code inside the main method.

  4. #4
    Junior Member
    Join Date
    Oct 2012
    Posts
    2
    My Mood
    Cool
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: My code is not working (method)

    code removed by moderator
    //this is rama krishna raju .if u like reply me
    Last edited by jps; October 15th, 2012 at 01:56 PM. Reason: spoonfeeding

  5. #5
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: My code is not working (method)

    @ramakrishnaraju
    Please see The problem with spoonfeeding.

Similar Threads

  1. How to Translate working code into code with a Tester Class
    By bankoscarpa in forum What's Wrong With My Code?
    Replies: 6
    Last Post: October 15th, 2012, 02:13 PM
  2. keyPressed method not working?
    By TP-Oreilly in forum What's Wrong With My Code?
    Replies: 5
    Last Post: December 29th, 2011, 09:43 AM
  3. random not working in .class method
    By Spidey1980 in forum Java SE APIs
    Replies: 13
    Last Post: August 19th, 2011, 07:35 AM
  4. method not working outside of class
    By Scotty in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 23rd, 2011, 10:00 AM
  5. contains method not working?
    By DudeJericho in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 19th, 2011, 01:57 PM