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
mestny [16]
2 years ago
15

Write a while (or for) statement to print all the digits of an int type variable x, one digit per line. For example, if int x

Computers and Technology
1 answer:
Vlada [557]2 years ago
7 0

<em>Complete Question:</em>

<em>Write a while (or for) statement to print all the digits of an int type variable x, one digit per line For example, if int x 38625, then the output should be in 5 lines as 60 (Hint: You may use built-in method to get a String representation of x then print out each character in String)</em>

***** Java *****

Answer:

import java.util.*;

public class Main{  

public static void main(String args[])  {  

Scanner input = new Scanner(System.in);

System.out.print("Enter an integer: ");

int x = input.nextInt();

String str = Integer.toString(x);  

for(int i =0;i<str.length();i++)  {

    System.out.println(str.charAt(i));

}

}  

}  

Explanation:

This line prompts user for input

System.out.print("Enter an integer: ");

This line gets user input

int x = input.nextInt();

This line converts user input to string

String str = Integer.toString(x);  

The following loop iterates through the converted string

for(int i =0;i<str.length();i++)  {

This prints each character on the string

    System.out.println(str.charAt(i));

}

You might be interested in
Tips for being confident and entertaining when presenting?
Mkey [24]
Okay, before you go on, do some power poses. standing with your arms up or your legs spread for like 10 minutes can greatly improve your mood. if you're in a classroom though, and can't do that, I would recommend making sure you have good posture while waiting to go up, and keep a smile on your face the whole time! even long before you start. smiling can increase your happiness a whole lot, so make sure you do it! also before the presentation, make sure you drink plenty of water (a gallon a day for the average adult) and get enough sleep. when preparing for your presentation, don't try to memorize the words you're going to say, (especially not if you'll have a reference like a paper or a slideshow) but memorize the ideas you want to convey. if you've written a speech, don't practice the speech exactly, practice conveying the ideas in it without reading from it. The worst thing you can do during a presentation is just stand there and read. Make sure you make eye contact and don't speak in monotone, tell a story with your presentation, don't just give information. if you need help being confident, I would suggest listening to some of your favourite music or some inspiring speeches (which you can find real easy on google<span>) to make you feel good about yourself. If you are having troubles with stage fright, or being in front of people, the best thing I've ever done, is just pretend they aren't there. Pretend you're just talking to yourself in your bedroom, and it becomes a lot more easy to express yourself. and if none of that sort of stuff works, maybe take some nerve medicine, if you have it. </span>
3 0
3 years ago
Stating a document is PDF or XPS document refers to document _______​
Sedbober [7]

Answer:

asxdfrthyjukilo;

Explanation:

3 0
3 years ago
Mateo could not find the undo command or shortcut. He should _____.
mr Goodwill [35]
Mateo should click on help.
5 0
3 years ago
Read 2 more answers
8.
mario62 [17]

Answer:

<em>Lillipop</em>

Explanation:

If you have your hands correctly placed on the keyboard, the only hand needed to type the word, "lillipop", is the left hand!

<em>Hope I was of Assistance</em><u><em> #SpreadTheLove <3</em></u>

5 0
2 years ago
In this exercise, you are given a word or phrase and you need to return that word or phrase with the word ‘like’ in front of it.
bogdanovich [222]

Answer:

See the link

Explanation:

There's exact same question on Brainly

brainly.com/question/15797916

7 0
3 years ago
Other questions:
  • How can we set the color of a text that acts as a link in a web page​
    10·2 answers
  • The syntax for accessing a class (struct) member using the operator -&gt; is ____.
    15·2 answers
  • A thin red border indicates the active cell. (True or False)
    12·1 answer
  • Wich technology can a website use to allow you to listen to a concert live over the internet?
    10·1 answer
  • 1. Which sentence best expresses the main idea
    12·1 answer
  • Write pseudocode for the question below:
    15·1 answer
  • Consider the following incomplete method. Method findNext is intended to return the index of the first occurrence of the value v
    15·1 answer
  • Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    6·1 answer
  • The disk you inserted was not readable by this computer
    11·1 answer
  • LAB: Phone number breakdown Given a long long integer representing a 10-digit phone number, output the area code, prefix, and li
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!