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
Alex builds a 1 GHz processor where two important programs, A and B, take one second each to execute. Each program has a CPI of
BigorU [14]

Answer:

attached below

7 0
3 years ago
Which of the following can be used to determine how much traffic a website is getting?
Bumek [7]
Analytics can be used to determine the amount traffic a website is getting. The correct option among all the options that are given in the question is the second option. Web analytics is used to determine several important information’s about a website. This feature can also be used to determine the region from which the maximum and the minimum traffic is arriving. Based on the information’s received from analytics, the website owner can take steps to improve the amount of traffic that is coming to the website.



6 0
3 years ago
______and______<br>are examples of utility<br>software.<br>can anyone say the answer ​
Viktor [21]

Answer:

File Management Tool

Compression Tool

Explanation: type it into the internet and the answer is there. :)

8 0
3 years ago
_____ returns the smallest integer greater than or equal to 7.3
Artist 52 [7]

Answer:

Explanation:

Required

Which returns smallest integer greater than or equal to 7.3

i.e.

x \le 7.3

When executed, the result of each instruction is:

ceil(7.3) = 8 -- This returns the smallest integer greater than 7.3

floor(7.3) = 7 --- This returns the smallest integer less than 7.3

<em></em>larger(7.3)<em> --- there is no such thing as larger() in python</em>

round(7.3) = 7 --- This rounds 7.3 to the nearest integer

From the above result,

8 is the smallest integer greater than or equal to 7.3

i.e.

8 \ge 7.3

Hence:

ceil(7.3) is correct

5 0
3 years ago
How to turn off do not disturb on iphone for a contact.
Tresset [83]

Answer:

Okay so you turn your phone on scroll up and it well show everything click the moon and on the side of your phone there is alittle swice turn it right

Explanation:

3 0
2 years ago
Read 2 more answers
Other questions:
  • Zach follows the instructions that show him how to create a custom Web site in his school's learning management system. These st
    14·1 answer
  • The physical address assigned each network adapter is called its ________.
    6·1 answer
  • To protect a computer, it is a good idea to install and frequently run
    6·2 answers
  • There are two main advantages to using multiple threads in a process: 1) Less work involved in creating a new thread rather than
    7·1 answer
  • What option for deploying software to users provides a link to install an application within Control Panel's Programs and Featur
    6·1 answer
  • Mary can view the thumbnails of her presentation slides when she’s creating the slides which element of the programs interface i
    8·1 answer
  • Why might a business choose a server-based network over a peer-to-peer network?
    15·1 answer
  • Scenario:
    10·2 answers
  • 1. Define the term M.A.N.
    5·2 answers
  • Hi can someone please help me with this homework please?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!