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]
2 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]2 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
Put these events in the order in which they occurred,
lakkis [162]

Answer:

  1. Local fisherman recover the body of Major Martin off the coast  of Spain .
  2. Spanish officials pass off the information in the briefcase to  German agents.
  3. Major Martin's name appears on a casualty list in a British  newspaper.
  4. Germany prepares for an imminent attack on the island of  Sardinia.

Explanation:

This above is the order in which Operation Mincemeat was executed in WW2 to deceive the Germans into believing that the Allies were going to invade the Balkans directly instead of Sicily which was their actual target.

The plan involved a fictitious Major Martin who had secret documents about the Allied invasion of the Balkans. After the body was released from a British submarine, it washed up in Spain where it was found by local fishermen.

Spanish officials then passed the information in the briefcase Major Martin had to German intelligence. To further reinforce the ruse, the British published Major Martin's name in a casualty list.

The Germans were thoroughly convinced and switched forces from Sicily for the defence of the Balkans and the island of Sicily.

5 0
3 years ago
Where do you go to create a workbook?​
Over [174]

Answer:

The explaination of this question is given below in the explanation section

Explanation:

The following steps are used to create a workbook.

1- Go to start menu and search about EXCEL (application software) and then click on it to open.

If you already opened a EXCEL's workbook, and you want to create a new workbook, then you follow the following steps:

  1. Click the File tab.
  2. Click New.
  3. Under Available Templates, double-click Blank Workbook. Keyboard shortcut To quickly create a new, blank workbook, you can also press CTRL+N.

A new workbook will be created.

6 0
3 years ago
​______________________ is a general security term that includes computer​ viruses, worms, and trojan horses.
VashaNatasha [74]
Malware
-------------------
6 0
3 years ago
How many binary digits does a single hexadecimal digit represent?
Anna35 [415]
Four binary digits.  So letter D.


8 0
3 years ago
Which device or appliance emits radio waves
ale4655 [162]
There are multiple devices that emit radio waves. The most obvious is are radiod and microwaves (yes, the food cooker). Wireless applicances also emit radio waves. But don't confuse everything to use microwaves. Some applicances use frequencies instead of radio waves. Some applicances that use frequencies are toy control remotes and a garage door.

I hope this helps! Please make sure ask me if you need more clarity!
8 0
2 years ago
Other questions:
  • Constructors ________. initialize instance variables when overloaded, can have identical argument lists when overloaded, are sel
    11·1 answer
  • One of the ways to create a horizontal navigation menu from an unordered list is to a. set the display property of the element w
    6·1 answer
  • Information flows:
    11·1 answer
  • The study of a current business and information system application and the definition of user requirements and priorities for a
    5·1 answer
  • Which guideline should you follow when selecting the font for a presentation
    9·1 answer
  • Can find error , suppose to print what season it is and if fails : Traceback (most recent call last):
    11·1 answer
  • Worksheet Identify the devices for moving the cursor around your computer screen
    12·1 answer
  • How to design remote access policy using the appropriate access controls for systems,applications, and data access
    6·1 answer
  • . Which responsibility belongs to the marketing function?
    11·1 answer
  • In this assignment you will be building an implementation of the hypothetical machine simulator like the one discussed in chapte
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!