I am working on to build a Sudoku programm. when i compile, i have many errors but i can't see the actual what error were they.
if (b == true);
^
bchimedochir_Sudoku1.java:184: error: <identifier> expected
if (b == true);
^
bchimedochir_Sudoku1.java:184: error: ';' expected
if (b == true);
^
bchimedochir_Sudoku1.java:184: error: illegal start of type
if (b == true);
^
bchimedochir_Sudoku1.java:184: error: <identifier> expected
if (b == true);
^
bchimedochir_Sudoku1.java:184: error: ';' expected
if (b == true);
^
bchimedochir_Sudoku1.java:186: error: illegal start of type
System.out.println("Congratulation !\n");
^
bchimedochir_Sudoku1.java:186: error: ';' expected
System.out.println("Congratulation !\n");
^
bchimedochir_Sudoku1.java:186: error: invalid method declaration; return type required
System.out.println("Congratulation !\n");
^
bchimedochir_Sudoku1.java:186: error: illegal start of type
System.out.println("Congratulation !\n");
^
bchimedochir_Sudoku1.java:187: error: <identifier> expected
System.out.println("This Sudoku is valid.\n");
^
bchimedochir_Sudoku1.java:187: error: illegal start of type
System.out.println("This Sudoku is valid.\n");
^
bchimedochir_Sudoku1.java:188: error: illegal start of type
else
^
bchimedochir_Sudoku1.java:188: error: ';' expected
else
^
bchimedochir_Sudoku1.java:190: error: illegal start of type
System.out.println("Sorry !\n");
^
bchimedochir_Sudoku1.java:190: error: ';' expected
System.out.println("Sorry !\n");
^
bchimedochir_Sudoku1.java:190: error: invalid method declaration; return type required
System.out.println("Sorry !\n");
^
bchimedochir_Sudoku1.java:190: error: illegal start of type
System.out.println("Sorry !\n");
^
bchimedochir_Sudoku1.java:191: error: <identifier> expected
System.out.println("This Sudoku is invalid.\n");
^
bchimedochir_Sudoku1.java:191: error: illegal start of type
System.out.println("This Sudoku is invalid.\n");
^
20 errors
bchimedochir@loki:~/F12_1400-005_prog7$ vim bchimedochir_Sudoku1.java
bchimedochir@loki:~/F12_1400-005_prog7$ javac bchimedochir_Sudoku1.java
bchimedochir_Sudoku1.java:184: error: illegal start of type
if (b == true);
^
bchimedochir_Sudoku1.java:184: error: <identifier> expected
if (b == true);
^
bchimedochir_Sudoku1.java:184: error: ';' expected
if (b == true);
^
bchimedochir_Sudoku1.java:184: error: illegal start of type
if (b == true);
^
bchimedochir_Sudoku1.java:184: error: <identifier> expected
if (b == true);
^
bchimedochir_Sudoku1.java:184: error: ';' expected
if (b == true);
^
bchimedochir_Sudoku1.java:185: error: illegal start of type
System.out.print("Congratulation !\n");
^
bchimedochir_Sudoku1.java:185: error: ';' expected
System.out.print("Congratulation !\n");
^
bchimedochir_Sudoku1.java:185: error: invalid method declaration; return type required
System.out.print("Congratulation !\n");
^
bchimedochir_Sudoku1.java:185: error: illegal start of type
System.out.print("Congratulation !\n");
^
bchimedochir_Sudoku1.java:186: error: <identifier> expected
System.out.print("This Sudoku is valid.\n");
^
bchimedochir_Sudoku1.java:186: error: illegal start of type
System.out.print("This Sudoku is valid.\n");
^
bchimedochir_Sudoku1.java:187: error: illegal start of type
else
^
bchimedochir_Sudoku1.java:187: error: ';' expected
else
^
bchimedochir_Sudoku1.java:188: error: illegal start of type
System.out.print("Sorry !\n");
^
bchimedochir_Sudoku1.java:188: error: ';' expected
System.out.print("Sorry !\n");
^
bchimedochir_Sudoku1.java:188: error: invalid method declaration; return type required
System.out.print("Sorry !\n");
^
bchimedochir_Sudoku1.java:188: error: illegal start of type
System.out.print("Sorry !\n");
^
bchimedochir_Sudoku1.java:189: error: <identifier> expected
System.out.print("This Sudoku is invalid.\n");
^
bchimedochir_Sudoku1.java:189: error: illegal start of type
System.out.print("This Sudoku is invalid.\n");
Here is my code.
import java.util.Scanner;
public class bchimedochir_Sudoku
{
public static void main(String args[])
{
Scanner input = new Scanner(System.in);
int r1c1;
int r1c2;
int r1c3;
int r1c4;
int r2c1;
int r2c2;
int r2c3;
int r2c4;
int r3c1;
int r3c2;
int r3c3;
int r3c4;
int r4c1;
int r4c2;
int r4c3;
int r4c4;
int total;
boolean b = true;
System.out.printf("Welcome to Sudoku Checker v1.0!\n");
System.out.printf("This program checks simple, small, 4X4 Sudoku grids for\n");
System.out.printf("correctness. Each column, row and 2X2 region contains the numbers\n");
System.out.printf("1 through 4 only once.\n\n");
System.out.printf("To check your Sudoku, enter your board one row at a time, with\n");
System.out.printf("Each digit separated by a space. Hit enter at the end of the row.\n\n");
System.out.print("Enter Row 1 :");
r1c1 = input.nextInt();
r1c2 = input.nextInt();
r1c3 = input.nextInt();
r1c4 = input.nextInt();
System.out.print("Enter Row 2 :");
r2c1 = input.nextInt();
r2c2 = input.nextInt();
r2c3 = input.nextInt();
r2c4 = input.nextInt();
System.out.print("Enter Row 3 :");
r3c1 = input.nextInt();
r3c2 = input.nextInt();
r3c3 = input.nextInt();
r3c4 = input.nextInt();
System.out.print("Enter Row 4 :");
r4c1 = input.nextInt();
r4c2 = input.nextInt();
r4c3 = input.nextInt();
r4c4 = input.nextInt();
System.out.print("Thank you. Now Checking ...\n\n");
sum = r1c1 + r1c2 + r1c3 + r1c4;
if (total == sum)
{
System.out.print("ROW-1:PASS\n");
} else
{
b = false;
System.out.print("ROW-1:FAILED\n");
}
sum = r2c1 + r2c2 + r2c3 + r2c4;
if (total == sum)
{
System.out.print("ROW-2:PASS\n");
} else
{
b = false;
System.out.print("ROW-2:FAILED\n");
}
sum = r3c1 + r3c2 + r3c3 + r3c4;
if (total == sum)
{
System.out.print("ROW-3:PASS\n");
} else
{
b = false;
System.out.print("ROW-3:FAILED\n");
}
sum = r4c1 + r4c2 + r4c3 + r4c4;
if (total == sum)
{
System.out.print("ROW-4:PASS\n");
} else
{
b = false;
System.out.print("ROW-4:FAILED\n");
}
sum = r1c1 + r2c1 + r3c1 + r4c1;
if (total == sum)
{
System.out.print("COL-1:PASS\n");
} else
{
b = false;
System.out.print("COL-1:FAILED\n");
}
sum = r1c2 + r2c2 + r3c2 + r4c2;
if (total == sum)
{
System.out.print("COL-2:PASS\n");
} else
{
b = false;
System.out.print("COL-2:FAILED\n");
}
sum = r1c3 + r2c3 + r3c3 + r4c3;
if (total == sum)
{
System.out.print("COL-3:PASS\n");
} else
{
b = false;
System.out.print("COL-3:FAILED\n");
}
sum = r1c4 + r2c4 + r3c4 + r4c4;
if (total == sum)
{
System.out.print("COL-4:PASS\n");
} else
{
b = false;
System.out.print("COL-4:FAILED\n");
}
sum = r1c1 + r1c2 + r2c1 + r2c2;
if (total == sum)
{
System.out.print("REG-1:PASS\n");
} else
{
b = false;
System.out.print("REG-1:FAILED\n");
}
sum = r3c1 + r3c2 + r4c1 + r4c2;
if (total == sum)
{
System.out.print("REG-2:PASS\n");
} else
{
b = false;
System.out.print("REG-2:FAILED\n");
}
sum = r1c3 + r1c4 + r2c3 + r2c4;
if (total == sum)
{
System.out.print("REG-3:PASS\n");
} else
{
b = false;
System.out.printf("REG-3:PASS %d\n",sum);
System.out.print("REG-3:FAILED\n");
}
sum = r3c3 + r3c4 + r4c3 + r4c4;
if (total == sum)
{
System.out.print("REG-4:PASS\n");
} else
{
b = false;
System.out.print("REG-4:FAILED\n");
}
}
if (b == true);
System.out.println("Congratulation !\n");
System.out.println("This Sudoku is valid.\n");
else
System.out.println("Sorry !\n");
System.out.println("This Sudoku is invalid.\n");
}