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 8011827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:07:50+00:00 2026-06-04T19:07:50+00:00

How do I enter a digit like ‘23423’ and output it like ‘2 3

  • 0

How do I enter a digit like ‘23423’ and output it like ‘2 3 4 2 3’? And how do I make it so that user cannot enter less or more than 5-digits?
(Your help would be appreciated. I just need hints from you guys since I’m learning Java. Looking forward to learn something new.)

This is what I have so far:

    Scanner input = new Scanner(System.in);

    int value1, value2, value3, value4, value5;

    System.out.print("Enter a number: ");
    value1 = input.nextInt();

    System.out.print("Enter a number: ");
    value2 = input.nextInt();

    System.out.print("Enter a number: ");
    value3 = input.nextInt();

    System.out.print("Enter a number: ");
    value4 = input.nextInt();

    System.out.print("Enter a number: ");
    value5 = input.nextInt();

    System.out.printf(" %d " + " %d " + " %d " + " %d " + " %d\n ", value1, value2, value3, value4, value5);
  • 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-04T19:07:52+00:00Added an answer on June 4, 2026 at 7:07 pm

    If you really want them to enter a single 5 digit number, you’re going to have to do validation on the users input and then give an error if the input isn’t valid. If the requirements are such that the first digit of your 5 digit number should never be zero, you can just get an int and then check if it is greater than 9999 and less than 100000. Otherwise take it as a string and check the length, then turn it into an integer once you have validated it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how to restrict user to enter only numbers with 6 digits and two decimal
If I enter something like this: a1.b22.333, I want it to output either: 1.22333
I'm trying to make a C function which will ask the user to enter
I want the user to enter a 4 digit number and the program must
int n ; n= (int)( javax.swing.JOptionPane.showInputDialog(null,enter a 3 digit no.)); Why does the above
enter code here Hi All, I have a simple windows service application that connects
enter code here I have a ListView that have a different Layout XML for
The cipher code actually works; it's just that I get some odd three digit
I am trying to write a function that prompts a user for a five
I have one textbox basically the user is going to enter in a 9

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.