Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

All program should be written in Java. Jav 1. (a An integer raised to another in

ID: 3913302 • Letter: A

Question

All program should be written in Java.

Jav 1. (a An integer raised to another integer evaluates to an integer value. For instance 2 (2 raised to power 3) will evaluate to 8 (i.e. 2 x 2 x 2). Write a method (function) that solves any integer raised to any integer. Assuming the declaration of the method is public int Power (int base, int power [10 marks] (b) Give 2 major drawbacks of using Machine language to write a program [5 marks] 2. (a) If the volume of a cone is given by the formula prh, where p 3.142, r is the radius of its base and h is its height, write a program that reads the radius and height, and calculates and prints out the volume of the cone. [12 marks] (b) Give any one way by which you could verify that the user types a numeric input for both the radius and the height in question 2(a). [3 marks] 3. (a) In your own words what do you understand by the term Interpreter? Give 2 examples. 5 marks] [5 marks] (c) Distinguish between a compilation error and a runtime error. 5 marks] (b) What is a compiler? Give 2 examples.

Explanation / Answer

Answering first full question. Please post 2 and 3 separately

1 a)

public class MyPower{
public int Power(int base, int power) {
int result = 1;
for(int i = 0; i < power; i++) {
if (result*base > 0) {
result *= base;
}
}
return result;
}
public static void main(String []args){
MyPower hw = new MyPower();
System.out.println("2^3 = " + hw.Power(2, 3));
}
}

Sample run

b) Drawbacks of machine learing:

i) Machine learning needs a lot of training data for future prediction.

ii) An another machine learning limitation is its not consistent