import java.io.*;
public class bonus{
public static InputStreamReader reader=new InputStreamReader(System.in);
public static BufferedReader input=new BufferedReader(reader);
public static void main(String[] args) throws Exception{
double salary,bonus;
System.out.println("Enter Employee's Monthly Salary: ");
salary=Double.parseDouble(input.readLine());
if(salary>=6000){
System.out.println("The bonus is 6000");
}
else
{
bonus=salary*.5;
System.out.println("The bonus is "+bonus);
}
}
}
}
// It only executes the System.out.println("Enter Employee's Monthly Salary: "); salary=Double.parseDouble(input.readLine());
//it does not executes the if - else block statements.....
//sample dialogue....
// Enter Employee's Monthly Salary:
//6000
lloydsbackyard
0
Light Poster
Recommended Answers
Jump to PostWell, are you entering anything after that prompt?
Jump to Post@lloydsbackyard
I dont know what you are talking about. When I ran your code, it worked perfectly:-
stephen@xxx:~/Development/java> javac bonus.java stephen@xxx:~/Development/java> java bonus Enter Employee's Monthly Salary: 6000 The bonus is 6000 stephen@xxx:~/Development/java>
Also just to inform you the code that you pasted contains an extra …
Jump to PostStephen: just a quick aside - how did you get the java tags into your message without them being interpreted as java tags?
All 9 Replies
masijade
1,351
Industrious Poster
Team Colleague
Featured Poster
stephen84s
550
Nearly a Posting Virtuoso
Featured Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
stephen84s
550
Nearly a Posting Virtuoso
Featured Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
lloydsbackyard
0
Light Poster
lloydsbackyard
0
Light Poster
lloydsbackyard
0
Light Poster
masijade
1,351
Industrious Poster
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.