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
Anuta_ua [19.1K]
3 years ago
14

Write an expression that executes the loop body as long as the user enters a non-negative number. Note: If the submitted code ha

s an infinite loop, the system will stop running the code after a few seconds and report "Program end never reached." The system doesn't print the test case that caused the reported message.
Computers and Technology
1 answer:
madam [21]3 years ago
3 0

Answer:

           while (Num>=0) {

               System.out.println("enter a another number");

               Num = in.nextInt();

           }

Explanation:

The complete java code prompting a user to enter a number until a negative number is entered is given below:

import java.util.Scanner;

public class num6 {

public static void main (String [] args) {

Scanner in = new Scanner(System.in);

System.out.println("enter a number");

int Num = in.nextInt();

while (Num>=0) {

System.out.println("enter a another number");

Num = in.nextInt();

}

System.out.println("Done.");

return;

}

}

You might be interested in
Off topic lol but does anyone know of a free app that lets you track family and friends like their location? Thx
prohojiy [21]

Answer:Life360 has a free version and a paid

Explanation:Life360 let’s you track family by placing them in “family circles” and then allows you to track their location once they accept the invite to the circle, you May also place specific areas that it will alert them entering and exiting.

4 0
3 years ago
Read 2 more answers
4.2.3: Basic while loop expression. Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Fol
wlad13 [49]

Answer:

import java.io.*;

import java.util.Scanner;

class divide {

public static void main (String[] args) {

    Scanner num=new Scanner(System.in);//scanner object.

    int userNum=num.nextInt();

    while(userNum>1)//while loop.

    {

        userNum/=2;//dividing the userNum.

        System.out.print(userNum+" ");//printing the userNum.

    }

}

}

Input:-

40

Output:-

20 10 5 2 1

Input:-

2

Output:-

1

Input:-

0

Output:-

No Output

Input:-

-1

Output:-

No Output.

Explanation:

In the program While loop is used.In the while loop it divides the userNum by 2 in each iteration and prints the value of userNum.The inputs and corresponding outputs are written in the answer.

4 0
2 years ago
Read 2 more answers
To print the last element in the array named ar, you can write :A. System.out.println(ar.length);
timofeeve [1]

Answer:

Option (d) is the correct answer.

Explanation:

An Array is used to store multiple variables in the memory in the continuous memory allocation on which starting index value is starting from 0 and the last index value location is size-1.

In java programming language the array.length is used to tells the size of the array so when the user wants to get the value of the last element, he needs to print the value of (array.length-1) location so the correct statement for the java programming language is to print the last element in the array named ar is--

System.out.println(ar[ar.length-1]);

No option provides the above statement, so option d (None of these) is correct while the reason behind the other option is not correct is as follows--

  • Option a will prints the size of the array.
  • Option b also gives the error because length is an undeclared variable.
  • Option c will give the error of array bound of an exception because it begs the value of the size+1 element of the array.
3 0
3 years ago
List some of the cautions related to costume change
Volgvan

Answer:

Costume Change?

Explanation:

You might not have enough time to complete the costume and it may look a little sloppy. Also, if you are in a play, everyone must be notified of the change.

4 0
2 years ago
If it malfunctions and I can throw it, then it's a hardware problem; if I have to yell at it because there is nothing to pick up
kobusy [5.1K]
Software problem.
Assuming "Software" is one of the available answers.

3 0
3 years ago
Read 2 more answers
Other questions:
  • Di bawah ini tampilan submenu pada tab menu insert pada microsoft word 2010,yaitu...
    6·1 answer
  • Mary is writing an article about the software development life cycle. She wants to place a flowchart besides the text. Which men
    6·2 answers
  • Texture fills are available to add as a slide background true or false
    7·2 answers
  • Question 1 Multiple Choice Worth 5 points)
    10·1 answer
  • In order to organize your work effectively on the computer, where is the best place to save it?
    14·2 answers
  • The first step in the information processing cycle is _____, which involves entering data into the computer.
    8·1 answer
  • Display all the natural numbers from 1 to 100 that are exactly divisible by 3 and 7 using FOR … NEXT. Without using Mod
    7·1 answer
  • Recall that in C++ there is no check on an array index out of bounds. However, during program execution, an array index out of b
    9·1 answer
  • Please please help I don’t understand this please.
    11·1 answer
  • When it comes to credit scores, why is having a
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!