1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kkurt [141]
3 years ago
6

Write a program that uses an array of integers initialized to whatever values you wish. Write a methods to calculate and return

the minimum and a method to calculate and return the maximum values in the array. Write an additional method that accepts the array as a parameter and then creates and returns a new array with all the same values as the original plus 10.
I think I have the max and min part down, but I need help figuring how to return the new array with all the same values as the orginal plus 10....

Here is what I have so far for the max / min. please use this in helping to create a matching method that accepts the array as a parameter. :

/*

*/
package arrayvalues;

/**
*
* @author dreadsguy
*/
public class ArrayValues {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int [] numbers = {99,56,103,9,31,63,81,92,13};

int m = maximum (numbers);
int n = minimum (numbers);


System.out.println("max ="+ m);
System.out.println("min ="+ n);


}


public static int maximum (int [] numbers){
//index
int i=0;
//current maximum
int max;
//initial maximum
max = numbers[i];
//calculate maximum

for (i = 1; i < numbers.length; i++){
if (numbers[i]> max)
{
max = numbers[i];
}

}
return(max);
}

public static int minimum (int [] numbers){
//index
int i=0;
//current minimum
int min;
//initial minimum
min = numbers[i];
//calculate minimum

for (i = 1; i < numbers.length; i++){
if (numbers[i]< min)
{
min = numbers[i];
}


}
return(min);
}
}
Computers and Technology
1 answer:
Sergeu [11.5K]3 years ago
6 0

Answer:

Here is the additional method you need to write:

<em>    public static int [] newArrayNumbers (int [] numbers){</em>

<em>    int [] newArray = new int[10];</em>

<em>    for (int i=0; i<numbers.length; i++){</em>

<em>        newArray[i]=numbers[i];</em>

<em>    }</em>

<em>    newArray[9]=10;</em>

<em>    return newArray;</em>

<em>    }</em>

The complete code is given in the explanation section

Explanation:

<em>import java.util.Arrays;</em>

<em>public class NewQues{</em>

<em>public static void main(String[] args) {</em>

<em>        int [] numbers = {99,56,103,9,31,63,81,92,13};</em>

<em>        int m = maximum (numbers);</em>

<em>        int n = minimum (numbers);</em>

<em>        System.out.println("max ="+ m);</em>

<em>        System.out.println("min ="+ n);</em>

<em>    System.out.println(Arrays.toString(newArrayNumbers(numbers)));</em>

<em> }</em>

<em>public static int maximum (int [] numbers){</em>

<em>        int i=0;</em>

<em>        int max;</em>

<em>        max = numbers[i];</em>

<em />

<em>        for (i = 1; i < numbers.length; i++){</em>

<em>        if (numbers[i]> max)</em>

<em>        {</em>

<em>        max = numbers[i];</em>

<em>        }</em>

<em>        }</em>

<em>        return(max);</em>

<em>        }</em>

<em>public static int minimum (int [] numbers){</em>

<em>        int i=0;</em>

<em>        int min;</em>

<em>        min = numbers[i];</em>

<em>        for (i = 1; i < numbers.length; i++){</em>

<em>        if (numbers[i]< min)</em>

<em>        {</em>

<em>        min = numbers[i];</em>

<em>        }</em>

<em>        }</em>

<em>        return(min);</em>

<em>        }</em>

<em>    public static int [] newArrayNumbers (int [] numbers){</em>

<em>    int [] newArray = new int[10];</em>

<em>    for (int i=0; i<numbers.length; i++){</em>

<em>        newArray[i]=numbers[i];</em>

<em>    }</em>

<em>    newArray[9]=10;</em>

<em>    return newArray;</em>

<em>    }</em>

<em>        }</em>

This for statement here does the work for you. assigning the values in the first array to the second array. <em>    </em>

<em>for (int i=0; i<numbers.length; i++){</em>

<em>        newArray[i]=numbers[i];</em>

<em>    }</em>

The second logic is, since you knew the first array had 9 elements, you create the second to have 10 elements so you can assign the element at the last index (9) the value of ten as required by the question

You might be interested in
How can you have a safe browser experience
goldfiish [28.3K]

Most likely the answer is to delete cookies, as it cuts down on the amount of tracking sites can do to you.

6 0
2 years ago
Which one of the following is not possible to view in the debug logs?
Usimov [2.4K]

Answer:

Formula field calculations

Explanation:

We can use debug logs to track events in our company, these events are generated if active users have trace indicators.

A debug log can register information about database operations, system processes and errors, in addition, we can see Resources used by Apex, Workflow Rules, Assignment Rule, HTTP calls, and Apex errors, validation rules. The only one we cannot see is Formula field calculations.

8 0
3 years ago
Write a function listLengthOfAllWords which takes in an array of words (strings), and returns an array of numbers representing t
vesna_86 [32]

Answer:

   public static int[] listLengthOfAllWords(String [] wordArray){

       int[] intArray = new int[wordArray.length];

       for (int i=0; i<intArray.length; i++){

           int lenOfWord = wordArray[i].length();

           intArray[i]=lenOfWord;

       }

       return intArray;

   }

Explanation:

  1. Declare the method to return an array of ints and accept an array of string as a parameter
  2. within the method declare an array of integers with same length as the string array received as a parameter.
  3. Iterate using for loop over the array of string and extract the length of each word using this statement  int lenOfWord = wordArray[i].length();
  4. Assign the length of each word in the String array to the new Integer array with this statement intArray[i]=lenOfWord;
  5. Return the Integer Array

A Complete Java program with a call to the method is given below

<em>import java.util.Arrays;</em>

<em>import java.util.Scanner;</em>

<em>public class ANot {</em>

<em>    public static void main(String[] args) {</em>

<em>       String []wordArray = {"John", "James", "David", "Peter", "Davidson"};</em>

<em>        System.out.println(Arrays.toString(listLengthOfAllWords(wordArray)));</em>

<em>        }</em>

<em>    public static int[] listLengthOfAllWords(String [] wordArray){</em>

<em>        int[] intArray = new int[wordArray.length];</em>

<em>        for (int i=0; i<wordArray.length; i++){</em>

<em>            int lenOfWord = wordArray[i].length();</em>

<em>            intArray[i]=lenOfWord;</em>

<em>        }</em>

<em>        return intArray;</em>

<em>    }</em>

<em>}</em>

This program gives the following array as output: [4, 5, 5, 5, 8]

7 0
3 years ago
10 computer and operating systems errors​
babunello [35]

Answer:

what is

Explanation:

3 0
2 years ago
Read 2 more answers
After a security incident is verified in a SOC, an incident responder reviews the incident but cannot identify the source of the
oksian1 [2.3K]

Answer:

Option A i.e., SME for further investigation.

Explanation:

Following the reports of such a security incident into an SOC, an incident respondent examines the incident but could not determine the cause of that same incident as well as establish an appropriate response protocol. The ticket for an incident must be applied to SME for even more inquiry. So, the following answer is correct.

5 0
3 years ago
Other questions:
  • Richard needs to copy information from another slide presentation that uses a different design template. To ensure that the info
    7·1 answer
  • Whitch event describes a festival in rio, brazil that includes a samba parade and eccentric outfits?
    13·1 answer
  • 2 Manter o autocontrole nos ajuda a evitar muitos problemas na nossa vida pessoal e no ambiente profissional. Em se tratando de
    14·1 answer
  • The foundation of secure communication on the internet replies on asymmetric encryption, with the use of Public and Private keys
    10·1 answer
  • If a filesystem has a block size of 4096 bytes, this means that a file comprised of only one byte will still use 4096 bytes of s
    12·1 answer
  • At which track meet did two runners finish in a time equivalent to the mode?
    14·1 answer
  • This isn't really a question ,but a random fact about Fnaf William Aton
    7·2 answers
  • How do you get off of the comments after you look at them wit out going all the way off the app?
    15·1 answer
  • What are price comparison websites?
    6·1 answer
  • Which file type is the best choice if the image will be made into a billboard?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!