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
What gaming PC should I get
zhuklara [117]

Answer:

ps5

Explanation:

8 0
2 years ago
Read 2 more answers
Which website can help you find antivirus software ?
sergey [27]

If you have windows you have Windows Defender Installed already!!

5 0
3 years ago
Two communicating devices are using a single-bit even parity check for error detection. The transmitter sends the byte 10101010
icang [17]

Answer:

The receiver will not detect the error.

Explanation:

The byte sent by transmitter: 10101010

The byte received by receiver due to channel noise: 10011010

If you see the bold part of the both sent and received bytes you can see that the number of bits changed is 2.

The two communicating devices are using a single-bit even parity check. Here there are two changed bits so this error will not be detected as this single bit even parity check scheme has a limit and it detects the error when the value of changed bit is odd but here it is even.

This parity scheme basically works well with the odd number of bit errors.

7 0
3 years ago
What kind of image does this photograph represent?
Drupady [299]
C architecture photograph
8 0
2 years ago
Read 2 more answers
An audiophile is a person who _______.
Andru [333]
An audiophile is a person who is enthusiastic about high-fidelity sound reproduction.
5 0
3 years ago
Read 2 more answers
Other questions:
  • . When you have multiple graphics positioned on a page, you can _______________ them so that they are a single graphic instead o
    9·1 answer
  • Write a set of pseudocode instructions to feed a pet, using at least five steps?<br><br> Thank you!!
    6·1 answer
  • In each iteration, selection sort (small) places which element in the correct location?
    9·1 answer
  • Crop marks are used on an illustration to indicate to the printer the
    10·1 answer
  • I’m trying to get answers from Brainly and it’s not showing up. I’ve been refreshing the browser, but it’s the same. I’ve never
    10·2 answers
  • What development in operating systems happened between the years 1990 and 2000?
    15·1 answer
  • Keyboards that are widely used on various smartphones and other small portable devices, and which are designed primarily for com
    15·1 answer
  • Advancements in nuclear science have led to technological advances which are both harmful and beneficial. Which would be conside
    15·1 answer
  • You're setting up some VMs to test an application you're considering making available to employees of the small company you work
    11·1 answer
  • What can you think of as a box or container that holds a value and has a label?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!