1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anna71 [15]
3 years ago
10

Write an application that inputs a five digit integer (The number must be entered only as ONE input) and separates the number in

to its individual digits using MOD, and prints the digits separated from one another. Your code will do INPUT VALIDATION and warn the user to enter the correct number of digits and let the user run your code as many times as they want (LOOP). Submit two different versions: Using the Scanner class (file name: ScanP2)
Computers and Technology
1 answer:
netineya [11]3 years ago
8 0

Answer:

The program in Java is as follows:

import java.util.*;

public class Main{

public static void main(String[] args) {

 int n, num;

 Scanner input = new Scanner(System.in);

 System.out.print("Number of inputs: ");

 n = input.nextInt();

 LinkedList<Integer> myList = new LinkedList<Integer>();

 for(int i = 0; i<n;i++){

     System.out.print("Input Integer: ");

     num = input.nextInt();

     while (num > 0) {

     myList.push( num % 10 );

     num/=10;

     }

     while (!myList.isEmpty()) {

         System.out.print(myList.pop()+" ");

     }

     System.out.println();

     myList.clear();

 }

}

}

Explanation:

This declares the number of inputs (n) and each input (num) as integer

 int n, num;

 Scanner input = new Scanner(System.in);

Prompt for number of inputs

 System.out.print("Number of inputs: ");   n = input.nextInt();

The program uses linkedlist to store individual digits. This declares the linkedlist

 LinkedList<Integer> myList = new LinkedList<Integer>();

This iterates through n

 for(int i = 0; i<n;i++){

Prompt for input

     System.out.print("Input Integer: ");

This gets input for each iteration

     num = input.nextInt();

This while loop is repeated until the digits are completely split

     while (num > 0) {

This adds each digit to the linked list

     myList.push( num % 10 );

This gets the other digits

     num/=10;

     }

The inner while loop ends here

This iterates through the linked list

     while (!myList.isEmpty()) {

This pops out every element of thelist

         System.out.print(myList.pop()+" ");

     }

Print a new line

     System.out.println();

This clears the stack

     myList.clear();

 }

You might be interested in
What type of slide show is a dynamic and eye-catching way to familiarize potential customers with what your company has to offer
Nat2105 [25]

Answer:

C. Office Clipboard

Explanation:

An Office Clipboard is a type of slide show that is a dynamic and eye-catching way to familiarize potential customers with what your company has to offer.

5 0
3 years ago
Read 2 more answers
You have enabled IP routing on PLABSA01 after enabling the IPRouter in the registry. How will you verify whether the IP routing
drek231 [11]

Answer:

By typing ipconfig at the command prompt

Explanation:

To check if an ip router is enabled in a registry, simply do the following:

1. launch your command prompt from accessories in your windows start button

2. Type this command IPconfig

3. Strike the enter button on the keyboard

It will display the various pack of upload and download indicating how packages are routed.

4 0
3 years ago
Critical Thinking Questions
Pani-rosa [81]

Answer:

Explanation:

1) Assassins Creed Valhalla. The developers (ubisoft?) is canadian i think. The culture of ACV is of the vikings. Some advantages would be many people could learn about viking culture but some concerns is since it may not be the developers culture some information could be wrong and many people could be misinformed

2) personally i would put them in the order of Asteroid, Pac Man, then modern warfare.

this is all i really know sorry

but i hope this helps <3

8 0
3 years ago
Read 2 more answers
Nappropriate use of technology makes it easier for cyber bullies to <br> others.
Alex
Inappropriate*
And yes
It does make it easier.
6 0
3 years ago
Read 2 more answers
Paragraph attributes are adjusted by clicking the _____ button.
Amiraneli [1.4K]

Answer:n the Paragraph group on the home tab, you use the Line and Paragraph Spacing button to adjust paragraph and line spacing.

With this group you can specify the text style and alignment of an entire paragraph.This  group includes a button for each of the four major types of alignment.

Read more on Brainly.com - brainly.com/question/8455181#readmore

Explanation:

3 0
3 years ago
Other questions:
  • Today, air travel allows large numbers of people to move quickly over long distances. Which of the following is a likely effect
    8·1 answer
  • The ____ function sums the numbers in the specified range and then divides the sum by the number of cells with numeric values in
    14·1 answer
  • Question 16 (2 points) Question 16 Unsaved
    11·1 answer
  • why is it important for you to understand and describe the internal and external components of a computer in the workplace​
    14·1 answer
  • What are basic difference between variable and data type in the c? ​
    6·1 answer
  • What is the most likely cause of a print job rendering the wrong colors on the output?
    14·1 answer
  • F(x) = -x^3-x<br> Is this function odd?
    15·2 answers
  • Why is it important to install updates? Why should you use the Power button on the Start menu instead of the Power button on you
    7·1 answer
  • What is professional education? <br><br><br><br><br>Please help me to do this.​
    7·2 answers
  • What is added to brining liquid to add flavour​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!