Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8835699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:19:06+00:00 2026-06-14T09:19:06+00:00

i am writing a program that needs to have 5 methods other than main

  • 0

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. . .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:19:07+00:00Added an answer on June 14, 2026 at 9:19 am

    Your problem is that you aren’t checking the value a second time. Try this:

    //System.out.print(check);
    while (validateNum() == false)
    {
        System.out.print ("Non-positive numbers are not allowed.\n");
        count = getNum();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a program that needs to read in very large files (about
I am writing a program that needs to run a java.jar server. I need
I'm writing a program that needs to print off high resolution .tiff images. The
I'm writing a program that needs to access a file inside of c:\program files\program_name\
I writing a JSP program that needs to react on an existing program. It
I'm writing a C program that needs good error handling. The code likes like
OK, so I am writing a program that unfortunately needs to use a huge
I am writing a program that needs to read a set of records that
I am writing a java program that needs to process a lot of URLs.
I'm writing an automation script on a production server that, among other things, needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.