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]
3 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]3 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
What does the Auto Fill tool do?
ki77a [65]
I believe this a microsoft tool it <span>It automatically populates data into cells that reference other cells :)

hope this helps</span>
7 0
4 years ago
Read 2 more answers
Which system is understood by the computer system​
WITCHER [35]

Answer:

Hey mate......

Explanation:

This is ur answer.....

<h2>Binary Number System </h2>

Hope it helps!

Brainliest pls!

Follow me! :)

4 0
3 years ago
Describe two ways methods that cab be used to help stop hacking
mojhsa [17]

Answer:

Use a firewall

Install antivirus software.

Explanation:

7 0
2 years ago
A wired laser printer is attached to a home computer. That printer has been shared so that other computers on the home network c
ohaa [14]

Answer:

peer-to-peer (P2P)

Explanation:

P2P peer-to-peer networking model is in use

3 0
3 years ago
What is a registered degree
dezoksy [38]

Answer:

I not sure

Explanation:

I think it's when a college student gets a degree for a job or something??? I dont know. I to young to know ;-;

lol

5 0
3 years ago
Other questions:
  • What are two reasons network devices are typically accessed through a cli?
    12·1 answer
  • On the Internet, you can use a(n)______to look for information on any topic, such as books, movies, scholarly articles, news, an
    6·2 answers
  • Material science focuses on<br><br> A) Heat<br> B) Solids<br> C) Liquids<br> D) Gasses
    7·2 answers
  • What runs horizontally and is identified with numbers?
    12·2 answers
  • 3. The combination of keys that we should press to select all document is
    14·1 answer
  • Which one is correct?
    7·2 answers
  • What technology habit you practice every day that you need to stop to be more successful?
    13·1 answer
  • Draw the hierarchy chart and then plan the logic for a program that calculates a person’s body mass index (BMI).
    11·1 answer
  • Julie has a difficult time seeing her computer Screen and uses adaplive technology tools to help he see better. One of the tools
    13·2 answers
  • Have you heard about Gold Opinions?<br><br> It is a new product that just came out.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!