I have written this simple program that is a basically a maths test. I would like to know is there any areas I can improve on and if I have any bad habits that would be useful to break now. I realise I could have written this in the main class, but I was trying to practice implementing other classes, so I tried to use a few classes.
Also, are there good practices that I am using that I should try to keep?
P.S. I don't usually use the comments I just added them to tell you what my intention is for a particular piece of code.
import java.util.Scanner;
import java.util.Random;
class Machine {
int num1, num2, ans, att;
int score = 0;
Random rand = new Random();
Scanner in = new Scanner(System.in);
public void sumGenerator(){
num1 = rand.nextInt(10);
num2 = rand.nextInt(10);
ans = num1 + num2;
System.out.println(num1 + " + " + num2 );
}//sumGenerator Method
public void answerGetter_score(){
att = in.nextInt();
if(att == ans){
score = score + 1;
System.out.println("Correct");
System.out.println("Score is currently: " + score + "/5");
}else{
score = score - 1;
System.out.println("Incorrect");
System.out.println("Score is currently: " + score + "/5");
}//else
}//answer Getter method
}//machine class
public class calcu {
public static void main(String[] args) {
Machine machine1 = new Machine();
System.out.println("***Welcome to addition Math test***");
for(int i=5; i>0; i--){
machine1.sumGenerator();
machine1.answerGetter_score();
}
System.out.println("Thanks for taking the test.");
}//main method