Internet Question Interview Report
- 7of 7 votes
AnswerWrite a method called createArray that accepts 4 parameters: number of rows, number of columns, a and b.
- mimiaarabi August 05, 2017 in United States
This method creates a 2-D array of number rows and columns as given in the parameter, then fills the array
with random values between a and b.
Write another method called checkColumn which accepts the position of the column, the min and max
elements of the array as parameter and returns true if the column contains both the minimum value and
maximum value, false otherwise.
Finding the min and max can be done in the main.
Sample run:
Enter number of rows and columns: 3 2
Enter 2 integers: 25 40
Array Elements:
26 32
39 28
27 30
Minimum: 26 Maximum: 39
Enter the position of the column to check: 0
Column 0 contains both min and max.| Report Duplicate | Flag | PURGE
Internet Question Java - 0of 0 votes
Answer[Applying a curve to grades] Write a method called “applyCurve” that takes as a parameter a single-
- mimiaarabi August 05, 2017 in United States
dimensional array called “grades” of integers and a single value integer called “raise”. This method should
modify the array “grades“, which contains the grades of students in a way that each value in the array is
added to it the curve value “raise”. You should check that the grades after applying the raise does not exceed
100.
For example, if array “grades” contains the following values:
95 100 24 43 76 51 87
0 1 2 3 4 5 6
After calling the method “applyCurve” with a raise value +7 the array grades would be as follows:
100 100 31 50 83 58 94
0 1 2 3 4 5 6
Write a test program (main) that prompts the user to enter the size of an array, the grades and the required
curve and then displays the grades after applying a required curve.
Sample run
Enter the array size: 7
Enter the grades: 95 100 24 43 76 51 87
Enter the required curve: 7
The grades after applying + 7 are: 100 100 31 50 83 58 94| Report Duplicate | Flag | PURGE
Internet Question Java - 0of 0 votes
AnswerWe need to develop a game that allows two players to throw a dice ten times and the player who gets the
- mimiaarabi August 05, 2017 in United States
highest sum wins the game.
Write a method sum(int[] values) that returns the sum of elements of the array values.
Write a method display(int[] values) that displays the elements of the array values.
Write a main method where you should:
a) Create two arrays of integers called player1 and player2 with size 10 both
b) For each player, generate ten random integers between 1 and 6 inclusively. The generated values
are added to the associated array of each player.
c) Display the generated values for each player.
d) Find and display the winner using the sum method.
Sample run
Generated numbers for player 1 are: 6 6 3 1 2 1 4 6 5 4
Generated numbers for player 2 are: 6 2 2 4 2 1 1 5 2 4
Player 1 wins with score 38| Report Duplicate | Flag | PURGE
Internet Question Java