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

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

Step by Step Solution

3.36 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!