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
You are asked to install a device that will combine several connections to the Internet and provide the sum of the available net
ch4aika [34]

Answer:

load balancer.

Explanation:

Based on the scenario being described within the question it can be said that you are being asked to install a load balancer. This is a device that behaves as a reverse proxy in order to correctly and efficiently distribute all the network traffic across various servers in order to increase the amount of users that can use the server at the same time.

8 0
3 years ago
Read 2 more answers
Uuhdcnkhbbbbhbnbbbbnnnnnnnnnfddjkjfs
Anna35 [415]

Answer:

The answer is "Option c"

Explanation:

In PHP to remove all the session variables, we use the session_destroy() function. It doesn't take any argument is required and then all sessions variables could be destroyed by a single call. If a particular clinical variable is now to be destroyed, the unset() function can be applied to unset a session variable. Its session doesn't unset or unset the session cookie by either of the local variables associated with it.

6 0
3 years ago
The set of instructions that tell the computer what to do are called ____.
CaHeK987 [17]
Hi,

The word you are looking for is "programs".

Hope this helps.
r3t40
4 0
3 years ago
Read 2 more answers
Suppose you want to use an Internet cafe to login to your personal account on a bank web site, but you suspect that the computer
kupik [55]

Answer:

Copy and paste the needed information from text editor to clipboard then to the web browser.

Explanation:

The keylogging software is an application that can connect to the keyboard API through software APIs or could be kernel based or hypervisor based, JavaScript based etc, to capture keyboard events.

It records these events which makes this tool useful for attackers in networks. So long as the clipboard logging or screen logging does not accompany the keyboard loggers, data can be copied on clipboard and pasted to the target point.

8 0
3 years ago
Which of the following protocols support the encryption and decryption of e-mail messages?
Katena32 [7]
It seems that you have missed the necessary options for us to answer this question so I had to look for it. Anyway, here is the answer. The protocol that supports the encryption and decryption of e-mail messages is this: <span>Secure Multipurpose Internet Mail Extensions (S/MIME) and Pretty Good Privacy (PGP). Hope this helps.</span>
7 0
3 years ago
Other questions:
  • EXPLAINING A URL
    15·1 answer
  • PLEASE HELP!
    13·2 answers
  • You listened to a song on your computer. Did you use hardware or software? Explain.
    11·2 answers
  • What describes the basic transaction data such as its date, purpose, and amount and includes cash receipts, canceled checks, inv
    13·1 answer
  • What is the smallest unit of data on the hard drive?
    5·1 answer
  • Jeremy Aronoff has purchased a new laptop. He wants to customize the operating system to meet his
    7·1 answer
  • Give the algorithm and flowchart for following C code:
    6·1 answer
  • A merchant bank and a merchant have been involved in a Web-based electronic transaction. Which of the following mediates between
    9·1 answer
  • Here’s my last question
    12·2 answers
  • Jobs that use math and science to solve problems involving the design and development of technologies can be found in the what c
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!