I have been working on this project for a week, and can not figure out what I have done wrong. It is supposed to accept a five digit number, then separate the number with three spaces between each number. So far all it does is not work, then spit out a line of red expletives basically saying that it doesn't work.
Can anyone point me in the right direction?
import java.util.*;
public class program1
{
static Scanner input = new Scanner (System.in);
public static void main (String [] args)
{
// variables and stuff
int num = 00000;
getnum();
separate_number(num);
}
// methods are here
public static void getnum()
{
int num;
do{
System.out.println("Please enter a five digit number");
num = input.nextInt();
if (num < 10000 || num > 99999)
{
System.out.println("The number is not five digits");
}
}while (num < 10000 || num > 99999);
}
public static int separate_number(int num)
{
int digit5, digit4, digit3, digit2, digit1;
digit5 = num % 10;
num = num / 10;
digit4 = num % 10;
num = num / 10;
digit3 = num % 10;
num = num / 10;
digit2 = num % 10;
num = num / 10;
digit1 = num % 10;
num = num / 10;
return Integer.parseInt(+ digit1 + " " + digit2 + " " + digit3 + " " + digit4 + " " + digit5);
}
}