You problems are, as you said in this piece of code.
public static void main(String[]args) {
Scanner kbd= new Scanner(System.in);
gm g=new gm();
g.a=kbd.nextInt();
g.b=kbd.nextInt();
System.out.print(+g.ab(int x));
System.out.println(":"+g.bc(int x);
}
Firstly, you are getting two ints from the user. You need a third int to be able to pass to the ab and bc methods.
Without this third int, it is hard to say what to do.
Before I get to that though, your print statements should look like this:
System.out.print(g.ab(x)); // Removed the + and the int
System.out.println(":"+g.bc(x)); // Added a ) at the end before the semi colon and removed the int
Now, as I said, you need a third int to act as the x.
The reason for this is, you are setting the g.a as one int, and g.b as the second int.
In your ab method, you either want x to be a, or x, but without a value for x, you do not know what x is. If you passed in a, you would just get a back anyhow. For instance,
System.out.print(g.ab(g.a));
would just give you a anyhow. The method would not have any function.
The same with bc.
System.out.println(":"+g.bc(g.b));
How to get the program to work as you seem to want it to?
Ok, what I would do is something like this.
public class gm {
int a,b; // Removd the x here.
public int ab() { // Removed the int x here.
// Added this code, removed your code.
if (a < 0)
a = 0; // You do not want a a negative number.
else {
while (a > 12) {
a = a - 12;
}
}
// You could have
// else {
// a = a % 12;
// }
// Instead of the else and while loop.
return a; // Return a, not return x.
}
public int bc() { // Removed int x here
// Added all of this, removed your original code
if (b < 0)
b = 0; // You do not want a negative minute.
else {
while (b > 59) {
b = b - 60;
a = a + 1;
}
}
return b; // Changed to return b.
}
Then in your main method,
System.out.print(g.ab());
System.out.println(":"+g.bc());
Good luck with it.