Java questions. Implement a class, Numerical, to perform the computations described
Java questions.
Implement a class, Numerical, to perform the computations described below.
• int sumTo(int m, int n), where m 6 n, to calculate m + (m + 1) + (m + 2) + · · · + n.
e.g. sumTo(1, 10) =55,
sumTo(9, 11) = 30.
• int sumSquareTo(int n), to calculate 12 + 22 + 32 + · · · + n2.
e.g.
sumSquareTo(2) = 5,
sumSquareTo(4) =30.
• int pow(int n, int k), to calculate nk. Note that n0 = 1.
e.g. pow(2, 10) = 1024,
pow(3, 2) = 9,
pow(3, 0) = 1.
• int sumPowTo(int n, int k), to calculate 1k + 2k + 3k + · · · + nk.
e.g. sumPowTo(4, 2)=30,
sumPowTo(5, 3)=225.