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]
2 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]2 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
I plugged my headphones into my computer, but the sound still came out of the speakers. help!
VARVARA [1.3K]

If you mean speakers. You should remove them or if you mean the speakers in the PC. Perhaps you put the headphones in the wrong one. Theres usually too one in the front and the other one in the back of the desktop.





Hope this helps.


Regards. Shaggy


Enjoy your music!

3 0
3 years ago
Read 2 more answers
If an application written for an earlier version of Windows doesn't run correctly the operating system can emulate its own older
n200080 [17]

Answer:

The answer is b) Right-clicking the program icon, clicking Properties, and then applying the required settings on the Compatibility tab.

Explanation:

If you have to run an application on a specific operating system, you have to configure the compatibility by accessing in its Properties, then Compatibility tab, and configure the operating system properly.

7 0
3 years ago
Which of the following would allow for the QUICKEST restoration of a server into a warm recovery site in a case in which server
adelina 88 [10]

Answer: C. Differential backup

Explanation: There are several ways od ensuring the preservation and storage of data even cases of disaster, one of such ways is data data mirroring which allows data to be replicated or copied in real time and several backup options. In cases where there there is need to restore a server, the warm recovery site provides a data or disaster recovery option used to mitigate the effect of data loss on organization. In the absence of data mirroring, differential backup option, provides the quickest recovery option as it only requires changes in the data stored after the last full backup. These speed experieced should be expected due to the relatively low data been dealt with rather than the entire data.

5 0
3 years ago
What is a office buttom?
SpyIntel [72]
The Microsoft button was exclusively used in the 2007 versions of word, excel, powerpoint, access and outlook. It has all of the different options like to save, print, open ect. It was located in the top left hand corner of the screen. It looked a bit like this (see attachment).

3 0
3 years ago
You have a website that sells widgets, and you have a category page specifically for blue widgets. After some extensive outreach
REY [17]

Answer:

It will increase your ranking on the homepage.

Explanation:

Widgets are easy to use software applications made up of one or more components.

Widgets will provide you with a quick access to information or data and there won't be any need to open the app that manages that information.

That is to say, without requiring you to open the app that manages a certain data or information you want to access, Widgets opens it for you.

For instance, The Calendar widget, provides you a quick view of your upcoming calendar events without opening the Calendar app.

Your rankings on the homepage will increase if more links are added to your blue widgets.

7 0
3 years ago
Other questions:
  • Directions Use your imagination and a word processor to write a business letter with two to three paragraphs. Your business lett
    5·1 answer
  • How do u get rid of this (the grey box)
    6·2 answers
  • A growing number of large organizations have built internal Web sites that provide opportunities for online social networking am
    7·1 answer
  • In Windows Vista, the Run command can be found in which application?
    6·1 answer
  • It skills which move well between industries are considered?
    11·1 answer
  • Which of the following is the answer?
    5·1 answer
  • To move an object to the bottom of the stack, click the Send Backwards arrow and then click Send to Back in the Arrange group on
    7·1 answer
  • Which amendment applies to the following scenario? “Brian attended church with his two daughters and wife on Sunday." A First B
    15·1 answer
  • Political parties to address the interest of civil society<br>​
    7·1 answer
  • 10 points + brainliest to first correect answer :) incorrect answers/ answers with no effort will be deleted this is easy im jus
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!