HS08TEST WA

Hi,

I have run this code against as many test examples I could fine and my answers match the test results.
My code is at http://www.codechef.com/viewsolution/3301834

I have tested for invalid EOF, and all conditions I think surround the problem. Obviously, I am missing something so I am asking for a pointer to what I am missing. Thanks to anyone available to help.

Robert Berman

Hey Robert,

I was able to take your code and with a slight adjustment get it to be accepted. I believe the issue occurs with the following line:

DecimalFormat numberFormat = new DecimalFormat("#,#### 0.00");

When I change this to the line below running the code results in an accepted verdict.

DecimalFormat numberFormat = new DecimalFormat("#.##");

If you wanted to see more on a step by step level how I diagnosed this as the problem you can look at a few of my previous submissions in which I was making adjustments to your code here:
http://www.codechef.com/status/HS08TEST,felic92

Hope it helps!

-Michael Feliciano

Hi Michael,

It is amazing how those statements you see as simple givens are so often the point of error, I looked everywhere but not at all at the format statement. Thank you for the lesson of “suspect the obvious”.
I tried to award you 10 points but the machine decided I was too generous.

Have an excellent week.

Robert

@bermanrl1 You can show your generosity by upvoting his answer and/or accepting it as a correct answer!!

Can you help with my code:
import java.util.Locale;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)  {
		Locale.setDefault(new Locale("en", "US"));
		//insert amount and balance
		Scanner input = new Scanner(System.in);
		
		int amount = input.nextInt();
		double balance = input.nextDouble();
		input.close();
		
		if ((amount > 0) && (amount < balance) && (amount % 5 == 0) && (balance>=0) && (balance<=2000)){
		System.out.printf("%.2f",balance-(amount + 0.50));
		}
		
		else {System.out.printf("%.2f",balance);}
	}
	}