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
frosja888 [35]
3 years ago
12

Define a method named swapValues that takes an array of four integers as a parameter, swaps array elements at indices 0 and 1, a

nd swaps array elements at indices 2 and 3. Then write a main program that reads four integers from input and stores the integers in an array in positions 0 to 3. The main program should call function swapValues() to swap array's values and print the swapped values on a single line separated with spaces.
Computers and Technology
1 answer:
Luba_88 [7]3 years ago
6 0

The program is an illustration of arrays.

Arrays are used to hold multiple values.

The program in java, where comments are used to explain each line is as follows:

import java.util.*;

public class Main{

   //This defines the method

public static int[] swapValues(int[] arr) {

   //This swaps the first and second array elements

       int temp = arr[0];

       arr[0] = arr[1];   arr[1] = temp;

   //This swaps the third and fourth array elements

       temp = arr[2];

       arr[2] = arr[3];   arr[3] = temp;

   //This returns the swapped array to main

       return arr;

}

//The main method begins here

   public static void main(String[] args) {

       //This creates a Scanner object

       Scanner input = new Scanner(System.in);

 //This declares an array of 4 elements

 int[] intArray = new int[4];

 //This gets input for the array

 for(int i = 0; i<4;i++){

     intArray[i] = input.nextInt();

 }

 //This calls the swapValues method

 intArray=swapValues(intArray);

 //This prints the swapped array

 for (int i = 0; i < 4; i++){

 System.out.print( intArray[i]+ " ");     }

}  

}

At the end of the program, the elements are swapped and printed.

Read more about similar programs at:

brainly.com/question/14017034

You might be interested in
What will be the code in CSS, to set
LUCKY_DIMON [66]

Answer:

font-family: Tahoma;

font-size: 7px;

text-decoration: underline;

Explanation:

As for the font-family, you can also specify the general font family to which the Tahoma font belongs.

4 0
3 years ago
Tristan has successfully deleted the blank row. The next thing he wants to do is to increase the length of the first column. A 2
Sonja [21]

Answer:

B

Explanation:

;)

4 0
3 years ago
Read 2 more answers
For Official Use Only (FOUO) and Controlled Unclassified Information (CUI) may include all of the following except: (circle one)
quester [9]

Answer

A. Secret Information

Explanation

For Official Use only is a security information term for designation applied by most governments. In the United States, it is used by the department of defense to handle orders for controlled Unclassified Information (CUI), and is strictly unclassified. The main purpose of this program is to eliminate inefficient and misleading patch work across agencies in the department of defense.


7 0
3 years ago
Read 2 more answers
Roger wants to give semantic meaning to the contact information, which is at the bottom of the web page. To do this
sdas [7]

Answer:

The answer is "Option b"

Explanation:

In the footer element, the roger uses parent element as the contact information because defined in critical analysis, in which critical thought is knowledge, in which it is widely applicable to life. It just implies that, logically and rationally, you evaluate details, its weaknesses, and strengths, and other options were wrong that can be described as follows:

  • Option a and Option d is not correct because that doesn't use this information section.
  • In option c, It is also not correct because it is related to the child.
7 0
3 years ago
Explain in your own words how you can use MSCONFIG and Task Manager to troubleshoot problems on the computer.
exis [7]

<u>Explanation:</u>

The MSCONFIG ( Microsoft System Configuration) tool is basically used for changing the computer's configuration settings. For example, the tool allows the user to prevent certain softwares from loading when the computer is turned on.

While the Task Manager as the name indicates allows the user to see all the programs currently running on the computer (including background processses). For example, a user can terminate certain programs by ongoing to the task manager.

8 0
3 years ago
Other questions:
  • What is the most important thing you should avoid when you store files and folders?
    13·1 answer
  • Look at the following Python code:
    11·1 answer
  • What is the answer to this?
    9·1 answer
  • Write a program with a loop that lets the user enter a series of positive integers. The user should enter −1 to signal the end o
    7·1 answer
  • A. What is MS-Word ? Write its uses.
    14·2 answers
  • HI How are you anyways are any of you intreseted in my giveaway
    7·2 answers
  • High level language - An object oriented programming language​
    5·1 answer
  • please help no one is helping me on this one
    9·1 answer
  • Please answer fast as soon as possible.
    11·1 answer
  • How do I find unwanted programs on my computer?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!