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
Subscribe too my you tube channel for a brainiest
dimaraw [331]

Answer:

Ok

Explanation:

4 0
2 years ago
When you ____ an exception, you send a message that an error has occurred to another part of the program.
jekas [21]
The correct answer is most definitely B
8 0
2 years ago
Read 2 more answers
Mention one application of AI from the real world and describe the use of of this application what is the type of learning used
gayaneshka [121]

Answer:

The real world AI application is Google Duplex. It is able to receive orders for making reservations. Then it calls the shop or the place and deals with the person and talks to him very fluently and informs you about the reservation. Some other general types of AI application are Google Assistant, Siri , Amazon Alexa and so on. But google Duplex is lot more advanced than them.

4 0
2 years ago
A microsoft windows os component responsible for representing graphical objects and transmitting them to output devices such as
vaieri [72.5K]
A driver. A driver is basicly and application or component that helps communicate between you computer and a device(a mouse, keyboard, printer etc.) You may have know when you get a new mouse and connect it up, Windows always tries to find a driver and download it. 
5 0
3 years ago
The 'client area' of a window is the area used to display the contents of the window (thus a title bar or border would lie outsi
Lady_Fox [76]

Answer:

<u>Window.java</u>

  1. public class Window {
  2.    int width;
  3.    int height;
  4.    public Window(int width, int height){
  5.        this.width = width;
  6.        this.height = height;
  7.    }
  8.    public int getWidth(){
  9.        return width;
  10.    }
  11.    public int getHeight(){
  12.        return height;
  13.    }
  14.    public int getClientAreaHeight(){
  15.        return getHeight();
  16.    }
  17. }

<u>Main.java</u>

  1. public class Main {
  2.    public static void main (String [] args) {
  3.        Window win1 = new Window(12, 15);
  4.        System.out.println(win1.getClientAreaHeight());
  5.    }
  6. }

Explanation:

<u>Window.java</u>

There is a Window class with two int type attributes, width and height (Line 1 - 3).

The constructor of this class will take two inputs, width and height and set these input to its attributes (Line 5 - 8). There are two methods getWidth and getHeight which will return the value of attributes width and height, respectively (Line 10 - 16).

The required new method getClientAreaHeight is defined in line 18 -20. This method will call the getHeight method to return the height value of the window (Line 19).

<u>Main.java</u>

We test the Window class by creating one Window instance and call the getClientAreaHeight method and print the return output (Line 1 -6).

We shall see 15 is printed.

4 0
3 years ago
Other questions:
  • Styles are modified by using the Office clipboard in the Home tab. true or false
    5·2 answers
  • While designing web pages for mobiles, the page content should be extensive such that the readers get the opportunity to explore
    5·2 answers
  • Which button would you use to quickly add addresses to a mail merge envelope?
    5·1 answer
  • Write a for loop to verify that your function is correctly returning the expected output for the radius values between 0 and 11.
    14·1 answer
  • What is the sum of each pair of binary integers? (assuming 8-bit register is used)
    5·1 answer
  • Taking away iPad privileges when a student hits another child would be considered a(an) ________ principle for decreasing or ext
    10·1 answer
  • In order for the image tag in an HTML file to function properly, the file named square.png must be located where?
    5·2 answers
  • What is the purpose of a mutator?
    8·1 answer
  • True or False The two types of general construction projects are residential for homes or dwellings and commercial for a commerc
    7·1 answer
  • SO I LIKE BOILED EGGS AND MY MUM WAS MAKING SALAD FOR DINNER SO I SAID DID YOU MAKE AND EGG-TRA ONE FOR ME
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!