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
Nick is moving from Alabama to Texas. A friend of his remarked that Nick may have to pay higher taxes there. What is the cheapes
Taya2010 [7]

Answer:

d is look up the Texas state website

Explanation:

because tell u about texas and taxes

3 0
3 years ago
____ increase network performance by reducing the number of frames transmitted to the rest of the network
Thepotemich [5.8K]

<u>Switches</u> increase network performance by reducing the number of frames transmitted to the rest of the network.

Switches are an integral part of networks assigned the role to serve as the means to share information among different devices.

Switches perform their function by supervising and controlling the flow of data to the intended devices thus preventing the undesired flow of data to all the devices in a network which improves the performance of the network. Switches can also play a role to prevent errors as it checks the data prior to transmitting the data forward.

Switches determine the devices to which the data packets are to be sent by using their media access control (MAC) address. All hardware units connected to a system have their unique MAC address. Switches identify the MAC address of the device that sends the frames and then interpret the MAC address of the target device thus preventing the frames to pass towards the rest of the network.

To learn more about switches, click here:

brainly.com/question/13484447

#SPJ4

6 0
2 years ago
What may happen if a large number of computer users are attempting to access a web page
Misha Larkins [42]
If the computers where all trying to access the same website then that website might be slow to load or it could crash all together.
7 0
3 years ago
You are building a gaming computer and you want to install a dedicated graphics card that has a fast GPU and 4GB of memory on bo
Lilit [14]

Answer: PCI- Express?

Explanation:

if that is an answer....

7 0
4 years ago
NEED HELP ASAP JAVA
Bas_tet [7]
I think is C tbh sorry if that’s wrong my fault
4 0
3 years ago
Other questions:
  • Describe a situation where it would be advantageous to use the copper tape or aluminum foil instead of the A and B push buttons
    7·2 answers
  • Write a multi-paragraph Informational essay about a current event in the news. You can develop your topic using
    8·2 answers
  • Write a program that accepts 5 number and arrange them in ascending order​
    7·1 answer
  • You have noticed that one of your DNS servers has possibly been compromised. You believe that a cached DNS entry for your domain
    8·1 answer
  • When shading paragraphs, Word shades from the left margin to the right margin of the current paragraph. True or false?
    5·1 answer
  • The question "How is traffic affected by fans leaving the stadium?" is related to which of the following?
    10·1 answer
  • What directs the read/write arm of the hard drive to where data exists and accesses it upon the user's request?
    8·1 answer
  • Suppose that we are using PDDL to describe facts and actions in a certain world called JUNGLE. In the JUNGLE world there are 4 p
    7·1 answer
  • Analyzing the role of elements in audio editing and Video
    7·1 answer
  • Please can someone help my assignment.​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!