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 did Adam and Eve look like?
Nata [24]
No one could possibly know, unfortunately.
6 0
3 years ago
Read 2 more answers
Please solve in 5 mins very fast​
Dmitriy789 [7]

Answer:

a. virtual reality

b. Master Boot Records

c. Primary function of a router

d. zoom

Explanation:

4 0
3 years ago
Read 2 more answers
Router 1 is configured with static NAT. Addressing on the router and the web server are correctly configured, but there is no co
marin [14]

Answer:

The router NAT configuration has an incorrect inside local address.

Explanation:

The term Inside in a <em>Network Address Translation (NAT) </em>context refers to networks owned by an organisation that must be translated. When NAT is configured, hosts within this network have addresses in one space (known as the local address space). These hosts appear to those users outside the network as being in another space (known as the global address space).

The term Outside refers to those networks to which the stub network connects, and which are not under the control of an organisation. Also, hosts in outside networks can be subject to translation, and can thus have local and global addresses

7 0
2 years ago
Households play a role in the circular flow of goods by
BaLLatris [955]

Answer:

People in households buy goods and services from businesses in an attempt to satisfy their unlimited needs and wants.

Explanation:

Households also sell their labor, land, and capital in exchange for income that they use to buy goods and services that firms produce.

6 0
3 years ago
Write a Box class whose init method takes three parameters and uses them to initialize the private length, width and height data
lord [1]

Answer:

Answered below

Explanation:

//Program is written in Java programming //language

Class Box{

private double length;

private double width;

private double height;

Box(double len, double wid, double hgt){

length = len;

width = wid;

height = hgt;

}

public double volumeOfBox( ){

double volume = length * width * height;

return volume;

}

public double getLength( ){

return length;

}

public double getWidth( ){

return width;

}

public double getHeight( ){

return height;

}

}

8 0
3 years ago
Other questions:
  • What is the term used for the document that describes the scenes and sequence of a game?
    6·1 answer
  • Why is it important to develop a research plan?
    5·1 answer
  • What is the result when you run the following program?
    12·1 answer
  • What component of Kerberos is responsible for storing keys for encrypting and decrypting data in the authentication process?
    13·1 answer
  • Write a loop that inputs words until the user enters STOP. After each input, the program should number each entry and print in t
    12·1 answer
  • What is a slide master ?
    8·2 answers
  • AP CSP - Write a program that takes 10 random numbers from 1 to 12 inclusively and averages them together.
    8·1 answer
  • Which cable would you check if you can't access any web pages?
    12·1 answer
  • Unleashes the ability of each person on their team to improve performance, solve problems, and
    6·2 answers
  • What is the purpose of "display:table"?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!