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

In java, Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space.

Example output for userNum = 20:

Computers and Technology
2 answers:
professor190 [17]3 years ago
8 0

Answer:

public class HelloWorld{

    public static void main(String []args){

       

        int userNum = 20;

       

        while(userNum!=1){

            userNum = userNum/2;

             System.out.print(userNum+" ");

        }

    }

}

Explanation:

Create the main function and declare the variable userNum with value.

then, use a while loop and it run until the userNum not equal to one when it become equal to 1 the while loop terminate.

Inside the loop, divide the userNum by 2 and then assign to userNum and this process continue until condition  true.

for example:

userNum = 20

userNum =20/2=10

then, 10/2=5

5/2=1

after that condition false. and while loop terminate.

Arturiano [62]3 years ago
8 0

Answer:

while(userNum > 1){

        userNum = userNum /2;

        System.out.print(userNum+" ");

     }

Explanation:

Probably don't need the print statement, but it doesn't cause an error.

You might be interested in
How many miss Dragon Ball Abridged?
Troyanec [42]

What is "Dragon Ball Abridged"?

3 0
3 years ago
Read 2 more answers
An employee wants to create a fake employee identification number as part of a fraud scheme. Which of the following controls wou
igor_vitrenko [27]

Answer:

The answer is "Self-Checking digits".

Explanation:

  • A self-check digit is a technique, that determines whether the identification number is valid or not. for example employee number, customer number, and invoice number.
  • It allocates by using the formula and the method, which will check that identified by a person that commits fraud by creating a false ID number.
4 0
3 years ago
1. Some of the music in the 1960s was used to protest social and political issues. Is music still used as a form of protest? Why
Nastasia [14]
It can be used as a form of protest still today, in fact many artists (drake,xxxtentacion,etc. rappers) protest in their rap today, like how donald glover in the song "this is america" was in a way protesting america by singing about the police brutality towards black people and how they are treated unfairly, he even did the jim crow dance in the song as well.
3 0
3 years ago
Write a program that reads a sentence as input and converts each word to "Pig Latin". In one version of Pig Latin, you convert a
OLga [1]

Answer:

The program statement will be written using Microsoft Visual C# Console

string val,vall;

Console.Write("Enter Sentence :");

vall = Console.ReadLine();

val = vall.ToUpper();

string[] words = val.Split(' ');

string[] word = new string[words.Length];

int kount = 0;

string newword = string.Empty;

for (int i = 0; i < words.Length; i++)

{

if (words[i].Length > 1)

{

char[] ch = words[i].ToCharArray();

for (int j = 1; j < words[i].ToCharArray().Length; j++)

{

newword += ch[j];

}

newword += ch[0] + "AY ";

word[kount] = newword;

kount++;

}

else

{

newword += words[i] + "AY ";

kount++;

}

}

Console.WriteLine(newword);

Console.ReadLine();

Explanation:

The first line declares two variables of string data-type

Line 2 prints "Enter Sentence" without the quotes

Line 3 accepts the sentence to be converted to Latin

Line 4 converts the sentence to uppercase

Line 5 splits the sentence word by word

Line 6 creates an array variable

Line 7 creates and initialise a variable kount to 0

Line 8 creates another variable newword,this variable would be used as output variable

Line 9 creates an iterative process

Line 11 checks if the length of a particular word in the sentence is a greater than one

If yes,

Line 13 to 20 Moves the first letter to the last then appends AY then saved in newword variable

If no,

Line 24 - 25 appends AY directly to the word currently in the iteration then saved in newword variable

Line 28 prints the Latin word equivalent of the input sentence.

6 0
3 years ago
Each array in Java has a public field named ________ that contains the number of elements in the array.
Helen [10]

Answer:

length.

Explanation:

length variable determines the size of the array or the number of elements in the array.length variable is a final variable.It is a public field.It is only applicable for array it is not applicable for strings.It is also used to directly access the field member of the array.So we conclude that the answer is length.

7 0
4 years ago
Other questions:
  • Which type of energy conversion is an electric generator designed to perform?
    8·1 answer
  • The ______________ steps through the source code, converting each source code instruction into appropriate machine language foll
    7·1 answer
  • ShellShock had the potential for an unauthorized user to gain access to a server. It affected many internet-facing services, whi
    11·1 answer
  • A table is a predesigned database that includes professionally designed database objects.
    12·1 answer
  • What software would you recommend for design?
    7·1 answer
  • Corinne is on a project team and they are in the project execution phase. She gets a call from a stakeholder to make a change to
    6·1 answer
  • When activated, an Excel object has all the features of an Excel ______?
    9·2 answers
  • Describe the different
    12·1 answer
  • The most effective technique of malware propagation among the following list
    7·1 answer
  • Which is the fastest memory in computer​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!