Solved

Throw exception when a condition is met

Posted on 2006-11-07
3
191 Views
Last Modified: 2010-03-31
Hi;
I would like to do the foll
if(totalDiscount > 100) then throw an Exception,when totalDiscount is a variable that holds all the associated discounts.
Thanks in advance
0
Comment
Question by:aswam1975
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 30 total points
ID: 17893153
if(totalDiscount > 100) {
    throw new RuntimeException("Total exceeded");
}
0
 
LVL 92

Expert Comment

by:objects
ID: 17893167
if(totalDiscount > 100) throw new IllegalArgumentException("Total discount cannot exceed 100");
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17893199
:-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
type mismatch (Object[] to double[] 4 33
Tomcat: Unable to run tomcat service. 2 23
throw exception 21 58
Is there a simpler dropbox system? 10 34
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question