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
Arisa [49]
3 years ago
13

I need to create a method named "root positive". which will either print the square root of the number passed to it or if the nu

mber is less than zero, it will print out the statement "Number must not be negative."?
1. Ask the user to input a number of type double which you will find the square root of the number.

2. Create a method called rootPositive which will either print the square root of the number passed to it or if the number is less than zero, it will print out the statement "Number must not be negative.".

3. Call your rootPositive method and pass to it the number the user enetered.
Computers and Technology
1 answer:
rjkz [21]3 years ago
5 0

Answer:

Explanation:

The following code is written in Java. It is a method that calculates the square root of a number as requested. The method first checks with an IF statement if the parameter value is a positive number and then calculates the square root and prints it to the screen. Otherwise, it prints Number must not be negative. A test case has been provided in the main method and the output can be seen in the attached image below.

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.print("Enter a number of type double to calculate square root:");

       double num = in.nextDouble();

       rootPositive(num);

   }

   public static void rootPositive(double num) {

       if (num > 0) {

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

       } else {

           System.out.println("Number must not be negative.");

       }

   }

}

You might be interested in
Boolean expressions are named after ____
zhuklara [117]
British mathematician George Boole
7 0
3 years ago
1k bits equals to how many bits
ruslelena [56]

Answer:

1000 bits

Explanation:

hope it helps :D

8 0
3 years ago
Java:
Agata [3.3K]

Answer:

import java.util.*;

public class work {

// function for counting unique character

public static int numUnique(String input) {

boolean[] list = new boolean[Character.MAX_VALUE];

for (int i = 0; i < input.length(); i++) {

list[input.charAt(i)] = true;

}

int count = 0;

for (int i = 0; i <list.length; i++) {

if (list[i] == true){

count++;

}

}

return count;

}

public static void main(String args[])

{

List<String>list=new ArrayList<>(); // creatng array list of type string

list.add("abcdef");

list.add("aaabcd");

list.add("bccddee");

list.add("abcddd");

list.add("a");

for(String str:list)

{

// for printing the results

System.out.println("given string : "+ str+" , number of unique values :"+numUnique(str));

}

}

}

Explanation:

5 0
4 years ago
A) Write a program that asks the user for the amount of money they will take on holiday and convert this into the equivalent amo
Lelu [443]

def func():

   money = int(input("How much money will you have on holiday? "))

   print("You will have {} euros.".format(int(money * 1.11)))

   money = int(money * 1.11)

   fifty = 0

   twenty = 0

   ten = 0

   five = 0

   while True:

       if money - 50 >= 0:

           fifty += 1

           money -= 50

       elif money - 20 >= 0:

           twenty += 1

           money -= 20

       elif money - 10 >= 0:

           ten += 1

           money -= 10

       elif money - 5 >= 0:

           five += 1

           money -= 5

       if money < 5:

           print("You will have {} fifties, {} twenties, {} tens, {} fives, and {} ones".format(fifty, twenty, ten, five, money))

           return

func()

I hope this helps!

5 0
3 years ago
Let S be an NP-complete problem and Q and R be two other problems not known to be in NP. Q is polynomial time reducible to S and
levacccp [35]

Answer:

B. R is NP Hard

Explanation:

Given:

S is an NP complete problem

Q is not known to be in NP

R is not known to be in NP

Q is polynomial times reducible to S

S is polynomial times reducible to R  

Solution:

NP complete problem has to be in both NP and NP-hard. A problem is NP hard if all problems in NP are polynomial time reducible to it.

Option B is correct because as given in the question S is an NP complete problem and S is polynomial times reducible to R.

Option A is not correct because R is not known to be in NP

Option C is not correct because Q is also not known to be in NP

Option D is not correct because Q because no NP-complete problem is polynomial time reducible to Q.

5 0
3 years ago
Other questions:
  • Teachers in most school districts are paid on a schedule that provides a salary based on their number of years of teaching exper
    10·1 answer
  • Which of the following refers to a marketing metric that shows an event that occurs on a Web page met a predefined goal associat
    6·1 answer
  • An automated search feature used by search engines to find results that match your search terms is called spider or
    13·1 answer
  • What government agency initially began the work with computers that would eventually lead to the development of the Internet?
    5·2 answers
  • What happens if the user sysadmin invokes the mail command interface and there are no unread mail messages?
    13·1 answer
  • The processor of a computer communicates to the other parts of the computer through a code that consists of what?
    9·1 answer
  • How do I get the bot token for discord? (scripting etc)
    5·1 answer
  • Builder Software is used to create _____? answers: 3d digital art design for cameras audio special effects
    5·2 answers
  • The largest amount of data, in bytes, which can be accomodated by a particilar network, link, or physical-layer is called the?
    14·1 answer
  • Java Provide the command to call the calcCirArea() function using a value of 15 for the circle’s radius and storing the result
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!