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
djyliett [7]
3 years ago
8

Write a method which will take one number as an argument. (Feel free to use static method or instance method) Given a input numb

er (integer) print the digits of the number. You must use while loop and modulus operator. This program must work for any positive integer. Negative integers are not cons idered as inputs.
Computers and Technology
1 answer:
astra-53 [7]3 years ago
7 0

Answer:

// here is code in java.

import java.util.*;

// class definition

class Main

{

// method that return the digits of number

   public static void dig(int num)

   {

   // while loop

       while(num>0)

       {

           // print the digits

           System.out.println(num%10);

           num=num/10;

       }

   }

   //driver method

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // scanner object to read input string

       Scanner s=new Scanner(System.in);

        // variable

       int num;

       System.out.print("please enter the number: ");

       //read the number

       num=s.nextInt();

       // validate the input, read a positive number only

       while(num<=0)

       {

           System.out.print("enter a positive number only:");

           num=s.nextInt();

       }

       System.out.println("digit of number are:");

       // call the function

      dig(num);

   }catch(Exception ex){

       return;}

}

}

Explanation:

Read a number from user and assign it to variable "num".Check if it is positive or not.If input is negative then ask user to again enter a positive number till user enter a positive number.Then call the function with input number. In this method it will find the digits of the number in the while loop using modulus "%" operator.

Output:

please enter the number: -345

enter a positive number only:1234

digit of number are:

4

3

2

1

You might be interested in
After an informative session, you find yourself with several pages of notes. For maximum retention and understanding, you should
creativ13 [48]
Hey there!

I would say that you should go over them within the least amount of time as possible. The amount that someone remembers after a lecture or informative session goes down greatly after only a few hours since the lecture, so it's best to review them within 8 hours or so. If you do it within this time, you will still have the greatest possible remembrance of what you learned, since your memory of this continues to diminish over the next few days. 

Hope this helped you out! :-)
7 0
3 years ago
In your own words, describe what Internet Protocols are. Why is it important to have agreed upon protocols?
Anni [7]

Answer:

Internet Protocol refers to a set of rules that govern how data packets are transmitted over a network. Internet protocol describes how data packets move through a network. Its important to have agreed upon protocols because Computers make use of protocols as well, to enable them to communicate. Devices need to communicate. When two devices want to successfully communicate, they must agree to follow some rules about the way they will do it.

8 0
3 years ago
Which transformation(s) can be used to map ARST onto
xenn [34]

Answer:

The last line i.e "rotation, then translation​ " is the correct answer .

Explanation:

Missing information :

In this question some information is missing The triangles are congruent by the SSS and HL. This line is missing in the given question .

The triangles that are the exactly similar sides and the angles.is known as congruent triangles .In the congruent  triangle  One's three sides are exactly similar in way of measuring to someone else's three sides also each of the three angles has almost the same angle as another.

  • In the congruent triangles firstly the reflection will applied then after the translation process is applied in the SSS and HL.
  • The other options are incorrect because they are not used for the mapping of RST into AWWX that's why these are incorrect option .  
6 0
3 years ago
1. cybersquatting refers to the tampering of existing web sites and selling unrelated products (true or false)
Dmitrij [34]

Answer:

i think its 17

Explanation:

i rerwerwerwrwerewr

5 0
3 years ago
What does SIP stand for?
agasfer [191]
Session Initiation Protocol, brainliest ?
4 0
4 years ago
Read 2 more answers
Other questions:
  • W jakim celu powstawały pieśni żołnierskie i partyzanckie?
    10·1 answer
  • Why is it important to not get distracted while driving?
    13·2 answers
  • What's a sentence with the words trickle and resume in it? they can be in any tense. Thanku​
    5·1 answer
  • If we can lock a file, we can solve the race condition problem by locking a file during the check-and-use window, because no oth
    14·1 answer
  • Hard and soft skills can both be transferable skills. *<br><br> True<br><br> False
    5·2 answers
  • Question 1
    10·1 answer
  • Hi I need help with an assignment. We're learning about encryption and decryption in code.org. i need help with three of the tex
    14·1 answer
  • Why would an end-user not generally buy a server? Explain your answer by referring to the typical role that servers perform. ​
    12·1 answer
  • 100 POINTS!!!!!!!
    15·2 answers
  • Most of the energy we use originally came from:
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!