posted message: A single term, simple derivative method in Java:
private static void deriv() {
Scanner scan = new Scanner (System.in);
int c, e;
String v;
System.out.print("Enter the constant: ");
c = scan.nextInt();
System.out.print("Enter the variable: ");
v = scan.next();
System.out.print("Enter the exponent of the variable: ");
e = scan.nextInt();
if (e==1)
{
System.out.println("The derivative is: " + c);
}
else
{
c *=e;
e--;
System.out.println("The derivative is: " + c + v + "^" + e);
}
}