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
leonid [27]
3 years ago
6

Write a java program called allDigitsOdd that returns whether every digit of a positive integer is odd. Return true if the numbe

r consists entirely of odd digits (1, 3, 5, 7, 9) and false if any of its digits are even (0, 2, 4, 6, 8). For example, the call allDigitsOdd(135319) returns true but allDigitsOdd(9145293) returns false.
Computers and Technology
1 answer:
Vlada [557]3 years ago
4 0

Answer:

public class Digits

{

   public static boolean allDigitsOdd(int num)

   {

       boolean flag=true;

       int rem;

       while(num>0)

       {

           rem=num%10;

           num=num/10;

           if(rem%2==0)    // if a even digit found immediately breaks out of loop

           {

               flag=false;

               break;

           }

       }

       return flag;     //returns result

   }

   public static void main(String args[])

   {

       System.out.println(allDigitsOdd(1375));    //returns true as all are odd digits

   }

}

OUTPUT :

true

Explanation:

Above program has 2 static methods inside a class Digits. Logic behind above function is that a number is divided by 10 until it is less than 0. Each time its remainder by 0 is checked if even immediately breaks out of the loop.

You might be interested in
Membrane-bound organelles are not found in the cells of A) bacteria. B) fungi. C) plants. Eliminate D) protists.
77julia77 [94]
The answer is A. Bacteria leave a thanks if i am correct please.
7 0
3 years ago
Read 2 more answers
Which of the these is tool for creating mobile apps? A:C# B:Apple Pie C:Appy Pie D:C++​
Ratling [72]

Answer:

bhsjsbsbsb

Explanation:

<h3><em>bejwnsusb</em></h3>
4 0
3 years ago
Read 2 more answers
Wamna play mm2<br><br><br>imma send u my username​
SashulF [63]

Answer:

sure send it lol but how

6 0
3 years ago
The freemen's bureau was the U.S.' first ____ program.​
Ludmilka [50]

Answer:

welfare

Explanation:

The Freemen's bureau was the first Welfare program in the US that was put forward in the year 1865 just after the assassination of Abraham Lincoln. It was headed by Oliver O Howard. And it was brought for providing the food, clothing, medical care, and education to the recently freed white refugees and the freed slaves. And it was supposed to be a kind of welfare.  

6 0
3 years ago
PLS HURRY!!!<br> Look at the image below!
max2010maxim [7]

Answer:

Ctrl+c

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • Do you believe that OOP should be phased out and we should start working on some alternative
    6·1 answer
  • Write a program that unpickle's employee dictionary and while reading from the dictionary, it allows users to lookup an employee
    9·1 answer
  • What are the functions of online gaming communities?
    12·1 answer
  • Client/server awareness. Visit three local stores in your neighborhood or mall and notice the information technology in the stor
    9·2 answers
  • Write a program that prompts the user for the lengths of the two legs of a right triangle, and which reports the length of the h
    8·1 answer
  • First Person Who Answers Fast As Possible Will Be Marked As Brainiest ​
    12·1 answer
  • Raul needs to ensure that when users enter an order into the tblOrders, the shipping date is at least two days after
    9·2 answers
  • If Laura wanted to solve a problem using recursion where the last statement executed is the call to the same method, what type o
    8·1 answer
  • Political parties to address the interest of civil society<br>​
    7·1 answer
  • The Open Systems Interconnection (OSI) Reference Model: defines standards for many aspects of computing and communications withi
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!