My code is not working (method)
Code :
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
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?
Re: My code is not working (method)
kevin is right, but i would start by putting some code inside the main method.
Re: My code is not working (method)
code removed by moderator
//this is rama krishna raju .if u like reply me
Re: My code is not working (method)
@ramakrishnaraju
Please see The problem with spoonfeeding.