Allo.

I am finishing up my coding project and I am going nuts trying to figure out what I'm doing wrong. I thought I finished my ISBN checker code properly, but when I finish imputing the ISBN number that is valid, I get "The ISBN number is valid", but I also get "Your ISBN number is not valid. The check number value should be 7". I am getting both responses. I get this each and every time I enter the info. What's going on here. I'm going crazy. haha.

public static void main(String[] args)
	{
		//prepare keyboard reader
		Scanner kbReader = new Scanner(System.in);
		
		int checkDigitSum = 0;
		
		//starts loop to read all 9 digits
		for(int i=1; i<=9 ;i++)
		{
			//prompt for input of digit i
			System.out.print("Enter digit" + i + " of ISBN:");
			
			//reads next digit
			int digit = kbReader.nextInt();
			
			
			//this line adds this digit times its order to the cumulative
			checkDigitSum = checkDigitSum + (i * digit);			
}
		//prompts for the check value
		System.out.print("Enter the check value:");
		
		//read Check Value and convert to lowercase value
		String checkValue = kbReader.next().trim().toLowerCase();
		
		//compute the calculated check value as remainder of division to 11
		int remainder = checkDigitSum % 11;
		
		//Convert to string
				String calculatedCheckSumValue = Integer.toString(remainder);
		
				//if the remainder is greater than 10 the check value is X
		if(remainder>=10)
			calculatedCheckSumValue = "x";
		
		//if the value matches it is valid
		if( checkValue.equals( calculatedCheckSumValue)){
			System.out.println("Your ISBN is valid.");
			
		}
		else{
}		
		//if it dosen't match 
		System.out.println("Your ISBN is not valid.The check value should be " + calculatedCheckSumValue);
}}

The } on line 43 closes the else {, so the print on line 45 is always executed.
If you indent your code properly (use a programmer's editor or simple IDE) then this kind of mistake becomes very obvious.

This question has already been answered. Start a new discussion instead.