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
8_murik_8 [283]
2 years ago
14

1.Write a Java program to solve the following problem using modularity. Write a method that rotates a one-dimensional array with

one position to the right in such a way that the last element becomes the first element. Your program will invoke methods to initialize the array (random values between 1 and 15) print the array before the rotation, rotate the array, and then print the array after rotation. Use dynamic arrays and ask the user for the array size. Write your program so that it will generate output similar to the sample output below:
Computers and Technology
1 answer:
Westkost [7]2 years ago
6 0

Answer:

Explanation:

The following code is written in Java and it asks the user for the size of the array. Then it randomly populates the array and prints it. Next, it rotates all the elements to the right by 1 and prints the new rotated array.

import java.util.ArrayList;

import java.util.Arrays;

import java.util.Random;

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       Random r = new Random();

       Scanner in = new Scanner(System.in);

       System.out.println("Enter Size of the Array: ");

       int arraySize = in.nextInt();

       ArrayList<Integer> myList = new ArrayList<>();

       for (int x = 0; x < arraySize; x++) {

           myList.add(r.nextInt(15));

       }

       System.out.println("List Before Rotation : " + Arrays.toString(myList.toArray()));

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

           int temp = myList.get(myList.size()-1);

           for (int j = myList.size()-1; j > 0; j--) {

               myList.set(j, myList.get(j - 1));

           }

           myList.set(0, temp);

       }

       System.out.println("List After Rotation :  " + Arrays.toString(myList.toArray()));

   }

}

You might be interested in
Write a program to enter 30 integer numbers into an array and display​
Rama09 [41]

Answer:

i764

Explanation:

3 0
2 years ago
Read 2 more answers
You wish to lift a 12,000 lb stone by a vertical
Shkiper50 [21]
Ndnsnskiaqosikejwnw sorry
3 0
3 years ago
The total number of possible keys for des is _________, which a modern computer system can break in a reasonable amount of time.
FinnZ [79.3K]
The answer is two. Most people think it's one but it's 2
3 0
3 years ago
Which symbol would be used in a flowchart to represent a connection to another part of the flowchart on the same page
AlekseyPX

Answer:

The answer is "Connectors".

Explanation:

Please find the Connectors image in the attached file.

In this question, the connectors symbol is usually small throughout the flowcharts. It is used as a connection to display and changes throughout the flux. It was usually marked by major letters that indicate jump points. This diagram visually shows the sequence of events in a system and who is accountable.

7 0
2 years ago
Which is a potential disadvantage of emerging technologies? A. increased spread of misinformation due to advanced communication
Sergio039 [100]

Answer: I believe it’s D.

Explanation: Less developed countries may not be able to afford the new technology, while more developed ones will be able to do so. Meaning the less developed countries will most likely not change.

8 0
2 years ago
Other questions:
  • A url consists of a ____, a domain name, sometimes the path to a specific web page or location in a web page, and the web page n
    11·1 answer
  • Which of the following is not one of DBA's tasks?
    14·1 answer
  • What are three requirements of information technology a. Accuracyb. _______________________________c. __________________________
    13·1 answer
  • What is the 16-bit hexadecimal representation of each of the following signed decimal integers?
    13·1 answer
  • Where (what memory location) is the data read from for the following code:
    12·1 answer
  • Please help! Answer this question if you know computer science very well. I need help with computer science.
    13·1 answer
  • Anyone has any ideas for a gaming setup i can buy for christmas. Something with high framing rates (monitor included) for about
    15·1 answer
  • Name:
    11·1 answer
  • Describe the uses of computer in different fileds? please help me ​
    14·1 answer
  • How to install an older version of prettier on yarn
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!