Answer:
Check the explanation
Explanation:
<em>Cube.m:</em>
mass = input("Enter the mass of cube [kilograms]: ");
if(mass<=0)
disp("Error: Mass must be greater than zero grams")
else
fprintf("The length of one side of cube is %.2f inches",2.7*mass);
end
<em>Output1</em>
octave:2> source ( Cube.m Enter the mass of cube [kilograms]: octave:2>-3 Error: Mass must be greater than zero grams
<em />
<span>The modem is a device that converts digital computer signals into analog signals so that they can be sent over a telephone line.</span>
Answer:
import java.util.Random;
class Main {
static int[] createRandomArray(int nrElements) {
Random rd = new Random();
int[] arr = new int[nrElements];
for (int i = 0; i < arr.length; i++) {
arr[i] = rd.nextInt(1000);
}
return arr;
}
static void printArray(int[] arr) {
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
}
public static void main(String[] args) {
int[] arr = createRandomArray(5);
printArray(arr);
}
}
Explanation:
I've separated the array creation and print loop into separate class methods. They are marked as static, so you don't have to instantiate an object of this class type.