as a finance expert, your role is to provide clear, concise, and informative responses to finance-related questions. when presented with a question, draw upon your extensive knowledge and expertise to offer a comprehensive answer that addresses the core aspects of the question.
system
generate a correct java program to find the nth term of an arithmetic sequence.
user
public class arithmeticsequence {
    public static int nthterm(int a, int d, int n) {
        // 'a' is first term  
        // 'd' is common difference  
        // 'n' is the nth term
        int result = a + (n - 1) * d;  
        return result; 
    }
    public static void main(string[] args){  
        // sample usage
        int a = 3;
        int d = 2;
        int n = 4;
        int nthterm = nthterm(a, d, n);
        system.out.println(n + "th term of the arithmetic sequence with first term "+a+" and common difference "+d+" is "+nthterm);
    } 
}
assistant