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
AlladinOne [14]
2 years ago
7

Write a complete Java program called Rooter that gets a positive integer called "start" from the user at the command line and th

en finds the squareroot of every number from "start" down to 0. Use a while loop to count down. Print each square root on a separate line. Include data validation to ensure the user provides a positive integer. Assume that the user enters an integer, and for validation, just check to be sure it is positive. If the validation is not passed, provide the user with suitable feedback and stay in the program to let the user try again until valid input is received. Use the Math.sqrt(double a) method to find each square root.
Computers and Technology
1 answer:
Nataly_w [17]2 years ago
4 0

Answer:

The program in Java is as follows:

import java.util.*;

import java.lang.Math;

public class Rooter{

public static void main(String[] args) {

    Scanner input = new Scanner(System.in);

 int start;

 System.out.print("Start: ");

 start = input.nextInt();

 while(start<=0){

     System.out.print("Number must be positive\nStart: ");

     start = input.nextInt();  }

 while(start>=0){

     System.out.println(Math.sqrt(start));

     start--;  }

}

}

Explanation:

This declares start as integer

 int start;

This prompts the user for input

 System.out.print("Start: ");

This gets input for start

 start = input.nextInt();

The following is repeated until the user input is valid i.e. positive

<em>  while(start<=0){</em>

<em>      System.out.print("Number must be positive\nStart: ");</em>

<em>      start = input.nextInt();  }</em>

The following while loop prints the square root of each number till 0

<em>  while(start>=0){</em>

<em>      System.out.println(Math.sqrt(start));</em>

<em>      start--;  }</em>

You might be interested in
What kind of negative social impact has wireless communications had on today's society?
Zarrin [17]
Kind of negative social impact has had today is debates on social networking and dating and wireless communications are destroying kids from ages 12-16 these 21st century devices are frying are worlds society.
5 0
3 years ago
Read 2 more answers
What is pressure?
Licemer1 [7]
"force per unit area" because pressure is force per unit area.

hope this helped
6 0
3 years ago
Read 2 more answers
The following code should take a number as input, multiply it by 8, and print the result. In line 2 of the code below, the * sym
Juli2301 [7.4K]

Answer:

num = int(input("enter a number:"))

print(num * 8)

Explanation:

num is just a variable could be named anything you want.

if code was like this num = input("enter a number:")

and do a print(num * 8)

we get an error because whatever the user puts in input comes out a string.

we cast int() around our input() function to convert from string to integer.

therefore: num = int(input("enter a number:"))

will allow us to do  print(num * 8)

6 0
3 years ago
A hacker using information gathered from sniffing network traffic uses your banking credentials from a recent transaction to cre
adell [148]

Answer: a replay attack, a replay attack is used so that the attacker can go sniff out the hash, and get whatever they are trying to get, then once it goes to the attacker it will go back to the original connection after replaying the hash

3 0
2 years ago
How do you suppose a request travels from one computer to another? How does the request know where to go?
Luden [163]
It can request a signal then transfer certain data points and provide the request. The request knows where to go using certain lines in the data.
4 0
2 years ago
Other questions:
  • A(n) ________ address is a temporary ip address assigned from an available pool of ip addresses.
    12·1 answer
  • Write a complete program to read two integers and display the number of integers that lie between them, including the integers t
    12·1 answer
  • Which member of the restaurant and food/beverage service career is mostly likely to plan menus and direct worker
    6·2 answers
  • OSHA's mission is to: A. Ensure that all workers receive adequate workers' compensation payments B. Esnure that all workers rece
    8·2 answers
  • What is the role of the osi application layer? provides control of all the data flowing between the source and destination devic
    5·1 answer
  • Multiple Choice
    6·1 answer
  • Which is the correct attribute syntax
    9·1 answer
  • Which of the following cameras is a high-end digital camera that has interchangeable lenses and uses a mirror to display on its
    13·1 answer
  • What is lasso tool write the name of any modelling and animation software<br>​
    8·1 answer
  • Please answer the following essay question:
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!