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
Nadusha1986 [10]
3 years ago
7

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

Computers and Technology
1 answer:
Ksenya-84 [330]3 years ago
3 0

Answer:

   while(userNum>=1){

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

       userNum--;

        }

Explanation:

This is implemented in Java programming language. Below is a complete code which prompts a user for the number, receives and stores this number in the variable userNum.

<em>import java.util.Scanner;</em>

<em>public class TestClock {</em>

<em>    public static void main(String[] args) {</em>

<em>    Scanner in = new Scanner (System.in);</em>

<em>        System.out.println("Enter the number");</em>

<em>    int userNum = in.nextInt();</em>

<em>    while(userNum>=1){</em>

<em>        System.out.print(userNum/2+" ");</em>

<em>        userNum--;</em>

<em>         }</em>

<em>    }</em>

<em>}</em>

The condition for the while statement is userNum>=1 and after each iteration we subtract 1 from the value of   userNum until reaching 1 (Hence userNum>=1)

You might be interested in
True or false.local and cloud backup differs in where the backup is saved
Feliz [49]

I think this is true.

7 0
3 years ago
Read 2 more answers
A customer contacts the help disk stating a laptop does not remain charged for more than 30 minutes and will not charge more tha
fenix001 [56]

Answer:

A. LCD power inverter

B. AC adapter

C. Battery

4 0
2 years ago
The BaseballPlayer class stores the number of hits and the number of at-bats a player has. You will complete this class by writi
atroni [7]

Answer:

class BaseballPlayer {

 private int hits;

 private int atBats;

 private String name;

 public BaseballPlayer(String n,int h,int a) {

   name=n;

   hits=h;

   atBats=a;

 }

 public void printBattingAverage() {

   double battingAverage = hits / (double)atBats;

   System.out.println(battingAverage);

 }

 public String toString() {

   return name + ": "+hits+"/"+atBats;

 }

}

public class Baseballtester{

 public static void main(String[] args){

   BaseballPlayer babeRuth = new BaseballPlayer("Babe Ruth", 2873, 8399);

   System.out.println(babeRuth);

   babeRuth.printBattlingAverage();

 }

}

Explanation:

The BaseballPlayer class is used to get and hold data of an instance of a baseball player. the instance object holds the name, number of hits and bats of the player.

The constructor is used to initialize the name, hits and atBats variables of an instance. The "printBattlingAverage" method returns the ratio of the hits and atBat variable while the string method "toString" returns the name and the hits to atBats ratio in string format.

7 0
3 years ago
Suppose a worker needs to process 100 items. the time to process each item is exponentially distributed with a mean of 2 minutes
stiks02 [169]
Suppose a worker nneeds to process100 items
7 0
2 years ago
Why might you use the "search network campaigns with display opt-in" campaign type?
slava [35]
The answer is:
You can use one budget to advertise on the Search Network and Display Network
5 0
2 years ago
Read 2 more answers
Other questions:
  • The strFirstName and strLastName variables contain the strings "Jane" and "Jones," respectively. Which of the following statemen
    14·1 answer
  • Software that manages and supports the resources of a computer is known as?
    10·1 answer
  • Which statement is true about the elements of the interface of a presentation program? The status bar appears at the top of the
    14·2 answers
  • The desktops of computers running the same OS all look the same
    8·1 answer
  • Write a program that prints the numbers 1 to 4 on the sameline with each pair of adjacent numbers separated by a single space(1
    5·1 answer
  • What is virtualization?
    11·2 answers
  • Any kind of brances in science
    13·1 answer
  • What are the names of the four major varnas in the caste system?​
    9·2 answers
  • Which finger presses the Shift key on the keyboard?
    6·2 answers
  • Name two materials that we can burn in order to get energy from biomass
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!