answer.
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
hjlf
2 years ago
11

. Write a statement that throws an IllgalArgumentException with the error message Argument cannot be negative.

Computers and Technology
1 answer:
dybincka [34]2 years ago
8 0

Answer:

public class PostAccount

{

  public void withdraw(float savings)

  {

     if (savings >=0 )

     {

        IllegalArgumentException exception

              = new IllegalArgumentException("Savings cannot be negative");

        throw exception;

     }

     balance = savings - withdraw;

  }

 }

Explanation:

IllgalArgumentException is a type of NumberFormatException  of runtime exception. Here in the program we have created an object of IllgalArgumentException class and after that we have thrown the error to show the condition if it does not satisfy the if condition.

You might be interested in
12) Suppose you wanted a subroutine to return to an address that was 3 bytes higher in memory than the return address currently
Snezhnost [94]

Answer:

.code

main proc

mov ecx,ebp

mov ecx, 787878

push ecx

call MySe7en

invoke ExitProcess,0

main endp

MySe7en PROC

pop ecx

sub ecx, 3

mov

push ecx

ret

end main

8 0
2 years ago
A mass m is attached to the end of a rope of length r = 3 meters. The rope can only be whirled around at speeds of 1, 10, 20, or
gayaneshka [121]

Answer:

Explanation:

Let's do this in Python. We know that the formula for the centripetal force caused by whirling the mass is:

F = m\frac{v^2}{r}

where v is the speed (1, 10, 20, 40) and r = 3 m is the rope length.

Then we can use for loop to try calculating the tension force of each speed

def maximum_speed(m):

    for speed in [1, 10, 20, 40]:

         tension_force = m*speed^2/3

         if tension_force > 60:

              return speed

    return speed

7 0
2 years ago
You are planning to implement dual stack of IPv4 and IPv6 in your network. Currently, your network consists of servers, routers,
AleksandrR [38]

Answer:

Ensuring that Internet Service Providers (ISPs) work with IPv6 .

Explanation:

An Internet Service Provider (ISP), it is the company that supply to other companies or an individuals for accessing the Internet and some other services such as virtual hosting and Web site building. ISP has the telecommunication line and an equipment to access the required point of area for the Internet.

4 0
2 years ago
Given an int variable k, an int array incompletes that has been declared and initialized, an int variable studentID that has bee
Feliz [49]

Answer:

check the explanation

Explanation:

Variables when it comes to programming are used to store data to be documented and manipulated in a computer program. They can also be used for labeling stored data with a descriptive name and any other needed details, so that the programs can be comprehended more understandably by the reader and ourselves.

to solve the question, we will write this set of codes;

numberOfIncompletes = 0;

for(k = 0; k < incompletes.length; k++)

{

       if(incompletes[k] == studentID)

           numberOfIncompletes++;

}

7 0
2 years ago
Write the definition of a method named add that receives a reference to a Scanner object associated with a stream of input consi
Lisa [10]

Answer:

import java.util.*;

class Main  

{

   public static void main(String[] args)

   {

       System.out.println("Enter integers and 0 to exit");

       Scanner a1=new Scanner(System.in);

       System.out.println(add(a1));

       

   }

  public static int add(Scanner a1)

  {

        int total = a1.nextInt();

          if (a1.hasNextInt())

              {

                 total =total +add(a1);

              }

       return total;

   }

}

Explanation:

The only thing that needs explanation here is hasnextInt. This returns true if entered number is integer and false if entered is not an integer. And rest is as shown in the program.

5 0
2 years ago
Other questions:
  • The basic components of cartridges and shotshells are similar. Shot pellets and a bullet are examples of which basic component?
    13·1 answer
  • Read this excerpt from The Outsiders. Or I could have gotten one of the gang to come along, one of the four boys Darry and Soda
    6·2 answers
  • Choose the correct sequence for classifier building from the following.
    7·1 answer
  • A class of Students was previously defined with the following properties: a string name, an integer age, a Boolean variable indi
    14·1 answer
  • Print "userNum1 is negative." if userNum1 is less than O. End with newline Convert userNum2 to 0 if userNum2 is greater than 8.
    10·1 answer
  • Ciscon Telecom is a mobile operator in the European Union. The company provides personalized services to its customers, and its
    8·2 answers
  • Write a method that accepts a String object as an argument and displays its contents backward. For instance, if the string argum
    10·1 answer
  • 6.4 Predicting Prices of Used Cars. The file ToyotaCorolla.csv contains data on used cars (Toyota Corolla) on sale during late s
    5·1 answer
  • The new Director of Information Technology has asked you to recommend a strategy to upgrade the servers on their network. Recomm
    9·1 answer
  • Distinguish among packet filtering firewalls, stateful inspection firewalls, and proxy firewalls. A thorough answer will require
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!