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
What is the correct sequence in which a computer operates​
GrogVix [38]

Answer:

Booting is a startup sequence that starts the operating system of a computer when it is turned on. A boot sequence is the initial set of operations that the computer performs when it is switched on. Every computer has a boot sequence.

8 0
3 years ago
What is the initial condition in this set of code?
marissa [1.9K]

Answer:An initial condition is an extra bit of information about a differential equation that tells you the value of the function at a particular point. Differential equations with initial conditions are commonly called initial value problems.

The video above uses the example

{

d

y

d

x

=

cos

(

x

)

y

(

0

)

=

−

1

to illustrate a simple initial value problem. Solving the differential equation without the initial condition gives you  

y

=

sin

(

x

)

+

C

.

Once you get the general solution, you can use the initial value to find a particular solution which satisfies the problem. In this case, plugging in  

0

for  

x

and  

−

1

for  

y

gives us  

−

1

=

C

, meaning that the particular solution must be  

y

=

sin

(

x

)

−

1

.

So the general way to solve initial value problems is: - First, find the general solution while ignoring the initial condition. - Then, use the initial condition to plug in values and find a particular solution.

Two additional things to keep in mind: First, the initial value doesn't necessarily have to just be  

y

-values. Higher-order equations might have an initial value for both  

y

and  

y

′

, for example.

Second, an initial value problem doesn't always have a unique solution. It's possible for an initial value problem to have multiple solutions, or even no solution at all.

Explanation:

5 0
2 years ago
A security administrator wants to empty the DNS cache after a suspected attack that may have corrupted the DNS server. The serve
MAVERICK [17]

Answer:

The easiest method to clear a DNS cache is to use either the command line, PowerShell or Windows Server's DNS Manager

Explanation:

You can use either the ipconfig /flushdns (command line), Clear-DnsClientCache (PowerShell) or DNS->(name)->Clear Cache (from the DNS Manager)

source:

https://activedirectorypro.com/clear-windows-dns-cache/

https://www.technipages.com/flush-and-reset-the-dns-resolver-cache-using-ipconfig

8 0
3 years ago
Read 2 more answers
How does polymorphism enable you to program "in the general" rather than "in the specific"? Discuss the key advantages of progra
barxatty [35]

Answer:

Explanation:

When programming in an OOP language classes are created to represent real-life objects, people, places etc. from the real world. Programming in the general allows you to cut down your code and making it more efficient by applying the same necessary functions to all of the objects that classify under the same category. For example by programming "in the general" and creating an Animal class you can create all of the functions/behaviors that animals tend to have. Then you can apply these functions/behaviors to various animals such as a Cat, Dog, Horse, etc. But if you program in the specific you cannot apply a Cat class to a Dog since they are not the same thing.

4 0
3 years ago
Wireshark capture files, like the DemoCapturepcap file found in this lab, have a __________ extension, which stands for packet c
grin007 [14]

Answer:

The answer is ".pcapng"

Explanation:

Wireshark format includes a "dump" with data packets, which is collected over a channel and sometimes a common folder to store, that data in the PCAP Next Iteration file system.

  • The .pcapng stands for the file system, this file system compatible with the recorded data transmission packet. It includes several data blocks.
  • It is quite robust, but it should not be helped by the other devices. Wireshark allows the libpcap system as well.
5 0
3 years ago
Other questions:
  • What are the differences between levels 1, 2 and 3 cache memoroes??
    8·1 answer
  • Philip is thinking about customizing his motorcycle. A paint job, saddlebags, and a radio would cost $600. His motorcycle is old
    15·2 answers
  • In an airline reservation system, on entering the flight number, the flight schedule and the flight status are displayed. In thi
    13·2 answers
  • Constraints are a. quantities to be minimized in a linear programming model. b. quantities to be maximized in a linear programmi
    5·1 answer
  • 4. How can you select non-adjacent cells (i.e. cells that are not all together in one block)?
    5·2 answers
  • In the history of Social Media what are two points that stood out?
    12·1 answer
  • Which is a common problem for inserting pictures into placeholders?
    10·1 answer
  • What is GIGO ?<br>plz answer me​
    7·1 answer
  • Setting up a desktop computer for anAutoCADspecialist who needs a minimum of 125 GBram which operating system would be the best
    5·1 answer
  • What is the binary number 0011 0011 multiplied by two?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!