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
Which IDEs support multiple high-level programming languages? Select all that apply.
rewona [7]

Answer:

The correct answer to this question is given below in the explanation section.

Explanation:

This question is about integrated development environments (IDEs) that support multiple high-level programming languages.

All mentioned IDEs such as Eclipse, Visual Studio, and Xcode support multiple high-level programming languages except Linux.

Using Eclipse, you can do Java programming easily and can build Java-based programs, and also you can do android programming in Eclipse while importing required android settings and libraries. Visual Studio is a Microsoft IDE, in which you can build desktop, web, and mobile, and windows phone app easily using high-level programming. Xcode is an integrated development environment for macOS containing a suite of software development tools developed by Apple for developing software for macOS, iPadOS, iOS, watchOS, and tvOS.

While Linux is not an IDEs, it is an open-source operating system based on Linux kernel.

8 0
2 years ago
What is gland? mention it's type​
stealth61 [152]

Answer:

Gland is an organ that makes one or more substances, such as hormones, digestive juices, sweat, tears, saliva, or milk.

TYPES OF GLANDS :

ENDOCRINE glands release the substances directly into the bloodstream.

EXOCRINE glands release the substances into a duct or opening to the inside or outside of the body.

BRAINLIEST PLEASE

5 0
2 years ago
Read 2 more answers
The function below takes a single string parameter: sentence. Complete the function to return everything but the middle 10 chara
dolphi86 [110]

Answer:

def get_middle_ten(sentence):

   ind = (len(sentence) - 12) // 2

   return sentence[ind:ind + 12]

# Testing the function here. ignore/remove the code below if not required

print(get_middle_twelve("abcdefghijkl"))

print(get_middle_twelve("abcdefghijklmnopqr"))

print(get_middle_twelve("abcdefghijklmnopqrst"))

7 0
2 years ago
Local laws passed councils are called
anzhelika [568]
An ordinance is the name typically used for a law passed by a local political subdivision, such as a city, county, village, or town. Ordinances may address a wide variety of local issues, from local government structure to speed limits and sign sizes.
4 0
3 years ago
Which options are available when a user modifies a recurring appointment? Check all that apply. Open this occurrence Open the fi
Rus_ich [418]

Open this occurence and open the series is the two options to choose from, from the dialog box that shows when attempting to modify the appointments

4 0
3 years ago
Read 2 more answers
Other questions:
  • 4 types of system software
    10·2 answers
  • A ____ is a type of program that uses a grid to organize and work with data.
    14·1 answer
  • What part of the computer gives access to the internet
    10·1 answer
  • What time does walmart deposit paychecks?
    5·1 answer
  • Give sally sue specific suggestions on how she can improve her powerpoint skills.
    6·1 answer
  • Most sus color in Among Us? Red is safe I saw him scan. I'll give brainliest because why not. I'm bored.
    14·2 answers
  • Wide area network (WAN) connects multiple networks that are in the same geographical locations.
    6·1 answer
  • What is printed to the console?<br> console.log(15 % 4);<br><br> 1<br><br> 2<br><br> 3<br><br> 4
    9·1 answer
  • 1. Write an if statement that assigns 20 to the variable y, and assigns 40 to the variable z
    10·1 answer
  • How do you fix this!!!!
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!