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
Given that a method receives three parameters a, b, c, of type double, write some code, to be included as part of the method, th
Debora [2.8K]

Answer and Explanation:

class Dis

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.println("Enter values for a,b,c");

double a=sc.nextDouble();

double b=sc.nextDouble();

double c=sc.nextDouble();

String s=discriminant(a,b,c);

System.out.println(s);

}

public String discriminant(double a, double b, double c)

{

double result;

result=(b^2-4ac);

if(result<0)

return "no real solutions"";

else return "";

}

}

Note:This program is written in JAVA

6 0
2 years ago
Read 2 more answers
PLSSSSSSSSSSSSSSSSSS HELPPPP I NEED THE ANSWER FAST!!! if an item that is purchased is digital, this may involve a direct (blank
Artist 52 [7]
The answer is
: deposit
8 0
2 years ago
Read 2 more answers
A company has a file server that shares a folder named Public. The network security policy specifies that the Public folder is a
klasskru [66]

Answer:

authentication

Explanation:

At the authentication process, there is a way of identifying a user, this is typically done by having the user enter a valid user name and valid password before access is granted. Here at authentication the process is based on each user having a unique set of criteria for gaining access.

The AAA server have to ascertain by comparing a user's authentication credentials with other user credentials stored in a database. In the event the credentials match, the user is granted access to the network. But on the other hand, If the credentials varies, and authentication fails then network access will be denied.

3 0
2 years ago
Google Apps are an example of​ ________. A. platform as a service​ (PaaS) B. software as a product​ (SaaP) C. platform as a prod
iogann1982 [59]

Answer:

Option E is correct.

Google Apps are an example of​ software as a service (SaaS).

Explanation:

I'll provide definitions to each of them.

Platform as a Service (PaaS): hardware and software tools available over the internet.

Software as a product (SaaP): product, software, which is made to be sold to users, and users pay for licence which allows them to use it. A good example of SaaP is the Microsoft Office package.

Platform as a product (PaaP): This creates a platform for product owners to put their products & for people to get their required products.

Infrastructure as a Service (IaaS): cloud-based services, pay-as-you-go for services such as storage, networking, and virtualization.

Software as a Service (SaaS): software that's available via a third-party over the internet.

From these definitions, it is clear that Google apps are examples of software as a Service because all the Google apps are software's that's available via a third-party over the internet.

Hope this Helps!!!

6 0
2 years ago
Python
Sergio039 [100]

Answer:

Check the explanation

Explanation:

from random import randint

def startGame(round,p1Name,p2Name,p1Wins,p2Wins):

print("\nPlaying round", round ,"of Beat That...")

print(p1Name,"rolls")

p1 = rollDice(p1Name)

print(p2Name,"rolls")

p2 = rollDice(p2Name)

if p1 > p2:

print(p1Name,"Wins this Round!")

p1Wins += 1

elif p2 > p1:

print(p2Name,"Wins this Round!")

p2Wins +=1

else:

print("The Players Tie this Round")

return p1Wins,p2Wins

def maxNumber(num):

a = []

for i in range(len(num)):

a.append(max(num))

num.remove(max(num))

maxNum = ''.join(map(str,a))

return maxNum

def getDiceRollValue(numOfDice):

num = []

for i in range(numOfDice):

a = randint(1, 6)

num.append(a)

return num

def rollDice(playerName):

rollValue = getDiceRollValue(numOfDice)

print(rollValue)

maxNumOutofRoll = maxNumber(rollValue)

print(playerName, "chooses",maxNumOutofRoll)

return maxNumOutofRoll

def winner(p1Name,p2Name,p1Wins,p2Wins):

print("Game Score:",p1Name,"has won",p1Wins,"rounds.",p2Name,"has won",p2Wins,"rounds.")

if p1Wins > p2Wins:

print(p1Name,"Wins This Game!")

elif p2Wins > p1Wins:

print(p2Name,"Wins This Game!")

else:

print("The Players Tie the Game")

numOfDice = 2

numOfRounds = 5

p1Name = "Player 1"

p2Name = "Player 2"

p1Wins = 0

p2Wins = 0

for i in range(1,numOfRounds+1):

p1Wins,p2Wins = startGame(i,p1Name,p2Name,p1Wins,p2Wins)

winner(p1Name,p2Name,p1Wins,p2Wins)

8 0
2 years ago
Other questions:
  • What does a sticky CTA do?
    9·2 answers
  • When seeking information on the internet about a variety of subjects the most useful place to look would be?
    13·2 answers
  • When conducting research, protecting the privacy of patients requires careful attention to ensure ?
    11·2 answers
  • FOREACH, EXPLODE and MAIL are examples of crazy functions.
    13·1 answer
  • Write an expression that executes the loop body as long as the user enters a non-negative number. Note: If the submitted code ha
    7·1 answer
  • Information systems cannot solve some business problems. Give three examples and explain why technology cannot help.
    11·1 answer
  • A 1.17 g sample of an alkane hydrocarbon gas occupies a volume of 674 mL at 28°C and 741 mmHg. Alkanes are known to have the gen
    14·1 answer
  • Assume you have a variable, budget, that is associated with a positive integer. Assume you have another variable, shopping_list,
    11·1 answer
  • Given main(), define the Team class (in file Team.java). For class method getWinPercentage(), the formula is:teamWins / (teamWin
    15·1 answer
  • In this exercise you will debug the code which has been provided in the starter file. The code is intended to take two strings,
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!