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

Recommended Answers

All 9 Replies

Well, are you entering anything after that prompt?

@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 "}".
And from the next time if put code in your post, please use code tags, for java code it is as simple as using:-
[code=java] and [/code] before and after your code respectively.

Stephen: just a quick aside - how did you get the java tags into your message without them being interpreted as java tags?

Hi James, you have to use the noparse tags around the code tags like this:-

[noparse] [code=xyz]

[/code]


[/noparse]

In fact check this post by John A for an even better option.

You can check the entire vB Code list here

Thanks!

Well, are you entering anything after that prompt?

It is now running it contains extra }...thanks problem solved!

@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 "}".
And from the next time if put code in your post, please use code tags, for java code it is as simple as using:-
[code=java] and [/code] before and after your code respectively.

Ok thanks......

ok thanks it runs perfectly now....

It is now running it contains extra }...thanks problem solved!

According to your comments it was outputting the prompt but wasn't running any further, but if this was the problem then it wasn't even compiling, and so wasn't running at all. So, either you weren't telling the truth then, or you are not telling the truth now. Which is it?

I say this only because if you want good help you need to provide accurate information.

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.