1. Write a piece of code that examines an array of integers named numbers and reports the...
Question:
1. Write a piece of code that examines an array of integers named numbers and reports the maximum value in the array. The array is initialized with
- int [] numbers = {5,10,3,8,9,11,25,6};
2. Write a piece of Java code that uses a while loop to repeatedly prompt the user to type a number until the user types a non-negative number, then square it.
- Example output:
Type a non-negative integer: -5
Invalid number, try again: -1
Invalid number, try again: 11
11 squared is 121
3. Write a method called determineDay. Given a number from 1-7, determineDay will return the name of the appropriate day (starting from Monday). Here is an example of a call to determineDay
String day = determineDay(1);
4. Write a method called allLess that accepts two arrays of integers and returns true if each element in the first array is less than the element at the same index in the second array. Your method should return false if the arrays are not the same length.
Java Program
Basic Technical Mathematics
ISBN: 9780137529896
12th Edition
Authors: Allyn J. Washington, Richard Evans