i am writing a program that needs to have 5 methods other than main each method does something specific, main calls all other methods outputs warning to users about incorrect input, second method just pulls main input of how many variables user wants to process, third method checks to make sure the user's input is non-negative and also checks all user input later to make sure it is also non-negative, fourth method tests the numbers the user inputs and lastly the last method prints everything.. so far im not doing so great. i have the program ask for user input which works fine, the second method which is supposed to check and make sure the input is correct i cannot seem to get to work it either loops saying the input is right or wrong. as the code is now it loops saying the input is incorrect.
import java.util.Scanner;
public class tgore_perfect
{
private static int count;
public static void main ( String args [])
{
count = getNum ();
boolean check = validateNum();
while (check == false)
{
System.out.print ("Non-positive numbers are not allowed.\n");
count = getNum();
}
if (check == true)
{
System.out.print("kk");
}
}
public static int getNum () //gets amount of numbers to process
{
Scanner input = new Scanner ( System.in );
int counter;
System.out.println ("How many numbers would you like to test? ");
counter = input.nextInt();
return counter;
}
private static boolean validateNum() //checks user input
{
if (count <= 0)
{
return false;
}
else
{
return true;
}
}
}
Doing this program through one main method is easy doing it through this many is just confusing to me. . .