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
A web application that is designed as a single piece of software with multiple features that are fully integrated into the main
Nookie1986 [14]

Answer:

c. Service oriented architecture (SOA)

Explanation:

In a service oriented architecture (SOA), a component of an application provides services to other components of the application or other applications majorly via a communications protocol over a network. In other words, SOA is a programming or software development technique in which services communicate with each other across different platforms.  

One key principle of SOA is to design an application (which in itself is a piece of software with multiple features) that is independent of any product, service, vendor or technology but can be integrated into other applications. SOA makes use of loose coupling -  a technique in which a client service remains independent of another service that requires it.

In contrast, a monolithic architecture aims at developing a software that is self-contained, independent and not to be integrated into other applications.

On another hand, Software as a service (SaaS), though a bit similar to SOA, is a model in which an application is made available to customers basically through a network. Users basically access the application via a browser.

Therefore, the best option is

C. Service oriented architecture.

3 0
3 years ago
How would you identify communication equipment?
eimsori [14]

Answer

Explanation:

There should be more context to this question but I would say there is a variety of things that could be seen as communication equipment, such as email, telephone, voice message, through mail.

6 0
3 years ago
If not cleared out, log files can eventually consume a large amount of data, sometimes filling a drive to its capacity. If the l
OLEGan [10]

Answer:

<u>/var</u>

Explanation:

The /var subdirectory contains files to which the system writes data during the course of its operation. Hence, since it serves as a system directory, it would prevent log files from consuming a large amount of data.

7 0
3 years ago
Read 2 more answers
I can’t get answers because the ads won’t load help me
Flura [38]

Answer: Get better wifi

Explanation: This maybe a router problem, Go to your router and reset it by unplugging the power chord, After 30 seconds plug it back in and wait for your wifi to start back up. Your ads should load now. Have a good day.

7 0
3 years ago
Reference variables allow arguments to be passed by ____________.
son4ous [18]

Answer:

Reference

Explanation:

The Reference type variable is such type of variable in C# that holds the reference of memory address instead of value. Examples for reference type are classes, interfaces, delegates and arrays.

We can pass parameters to the method by reference using <em>ref </em>keyword

It’s mandatory to initialize the variable value before we pass it as an argument to the method in c#

For example,

int x = 10;  // Variable need to be initialized

Add(ref x); // method call

If you pass parameters by reference in method definition, any changes made to it affect the other variable in method call.

Here's a sample program:

using System;

namespace ConsoleApplication

{

   public class Test

   {

       public static void Main()

       {

           int i = 10;

           Console.WriteLine("i=" + i);

           Add(ref i);

           Console.WriteLine("i=" + i);

           Console.ReadLine();

       }

       public static void Add( ref int j)

       {

           j = j + 10;

           Console.WriteLine("j="+j);

       }

   }

}

Output:

i=10

j=20

i=20

7 0
3 years ago
Other questions:
  • Mile markers appear as _____ green signs.
    6·2 answers
  • Which component of a computer is its input device and what role does it play in a document?
    6·1 answer
  • How can you have a safe browsing experience
    5·1 answer
  • Complete the below function which dynamically allocates space to a 3d array of doubles, initializes all values to 0, and returns
    8·1 answer
  • what are examples of conditional formatting tools? check all that apply. color scales, icon sets,data bars,cell styles,themes
    8·1 answer
  • The amount of pressure a power source creates to move electrons. *
    9·1 answer
  • Which statement is true about hacking?
    11·2 answers
  • 1 point
    13·1 answer
  • What do the last two steps in the cyclical design process most likely involve
    6·1 answer
  • When a file is used by a program, there are three steps that must be taken:
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!