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
A computer memory that acts as the main storage available to user for programs and data
Gelneren [198K]

Answer:

Primary storage. Primary storage (also known as main memory, internal memory, or prime memory), often referred to simply as memory, is the only one directly accessible to the CPU.

3 0
2 years ago
You and three of your friends decide to hike the Appalachian Trail, a 2175-mile trail running from Georgia to Maine, starting wh
kozerog [31]

Answer:

The things to do:

a. Lie down flat.

b. Call your friend on phone to inform him of the situation, if he is not already aware.

c. Instruct him to call the rescue team and a helicopter ambulance.

d. Make a video call to your doctor and ask her for first aid instructions.  She can use HIPAA compliant video-conferencing tools to initiate consultations and treatment with you from the far distance.

e. Follow your doctor's instructions.

Explanation:

Telemedicine is the extension of medical services to patients in remote places.  This practise is facilitated by the use of telecommunication devices and telemedical equipment.  Telemedicine is made possible by technological advancements.  Many healthcare practitioners have embraced the practice and offer their patients telemedical services as the need arises.

Modern technology has enabled doctors to consult patients by using HIPAA compliant video-conferencing tools.

HIPAA stands for the Health Insurance Portability and Accountability Act of 1996, which was enacted by the 104th United States Congress and signed by President Bill Clinton in 1996.  The Act encourages Healthcare access to remote patients, medical consultation and treatment portability, and secures health information, among others.

7 0
3 years ago
What is a way to minimize techniacl problems with your computer.
Vsevolod [243]
Have you tried turning it off and back on.Try that if that does not work then try debugging it
3 0
3 years ago
Read 2 more answers
Why is it important to recognize web address endings? to know the type of information on a site to determine if the site’s infor
seraphim [82]

Answer: To know the type of information on a site.

Website address endings are known as domain extensions. In our current society, the domain extensions or website endings are indicators of what information or content the website will contain. By recognizing these domain extensions, you will have a clear understanding of what to expect from the website.

Some examples of these domain extensions are:

.edu

- The .edu extension indicates that the website is related to educational content.

.org

- The .org extensions indicates that the website is related to free organizations.

.com

- The ever famous .com extension is an indicator of a commercial type of website.

6 0
3 years ago
Read 2 more answers
Cisco's acquisition of Pure Digital, makers of the Flip video camera line, was largely considered a flop because comparable tech
juin [17]

Answer:

True

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following describes the difference in light intensity between the brightest white and the darkest black that can be
    15·1 answer
  • What are the advantages of homogenation
    5·1 answer
  • Which one of the following rules for selecting a password is the best?
    5·2 answers
  • Which of the following statements is false? a. A class can directly inherit from class Object. b. If the class you're inheriting
    14·1 answer
  • Executives of a company deal less with details of the operational activities and deal more with the higher meaningful aggregatio
    14·1 answer
  • A __________ infrastructure is made available to the general public or a large industrygroup and is owned by an organization sel
    11·1 answer
  • Function _one(array)
    6·1 answer
  • CSCU EXAM TEST FINAL1-A software or hardware that checks information coming from the Internet and depending on the applied confi
    6·1 answer
  • Page No
    10·1 answer
  • Your task is to build a palindrome from an input string.A palindrome is a word that readsthe same backward or forward. Your code
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!