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
Gala2k [10]
3 years ago
12

Make sure to read all of these specifications carefully. Write a function, named array_shifter, that accepts an array of doubles

and the array’s size as arguments. The function should create a new array that is one element larger than the argument array.
Computers and Technology
1 answer:
rosijanka [135]3 years ago
6 0

Answer:

import java.util.Arrays;

public class num2 {

   public static void main(String[] args) {

//Create and initialize the first array        

double [ ]arr = {3.5, 5.6, 4.5, 6.7};

// Get the length of the array

       int n = arr.length;

      //Call the method Array Shifter inside the output statement

       System.out.println(Arrays.toString(array_shifter(arr,n)));

   }

   static double [] array_shifter(double [ ] doubleArray, int n){

       double [] narr = new double[n+1];

       //Loop through from index 1

       for(int i =0; i<narr.length-1; i++){

           narr[i] = doubleArray[i];

       }

       //Put a new element at the last index

       narr[narr.length-1] = 1.1;

       return narr;

   }

}

Explanation:

This is implemented in Java

Read detailed comments in the solution

The method array_shifter creates a new array that is one element larger than the array it received as argument and returns it

You might be interested in
Personal Web Page Generator Write a program that asks the user for his or her name, then asks the user to enter a sentence that
Fudgin [204]

Answer:

see explaination

Explanation:

The following code is in python 3.5 and above:

# Create a main method

def main():

# Accept name from the user

name = input("Enter your name: ")

# Accept describe yourself from the user.

describe = input("Describe yourself: ")

# Create a file object

f = open('person.html','w')

# Creat a string to store the html script.

message = """<html>

<head>

</head>

<body>

<center>

<h1>"""+name+"""</h1>

</center>

<hr/>"""+describe+"""<hr/>

</body>

</html>"""

f.write(message)

f.close()

main()

7 0
3 years ago
How many answers do you need to be able to write messages on here??
Kipish [7]

1,000

Hope this helps!



~Courtney

3 0
2 years ago
Imagine the user types in a complete sentence, but we want to read only the first word and place it in the String variable word.
Vladimir [108]

Answer:

import java.util.Scanner;

public class FirstWord {

   public static void main(String[] args) {

       //NOW YOU WANT TO COLLECT INPUTS FROM THE STUDENT OR USER

       //IMPORT THE SCANNER CLASS FIRST  outside your class

       // THEN YOU CREATE AN OBJECT OF THE SCANNER CLASS

       Scanner input = new Scanner(System.in);

       

       //CREATE A VARIABLE TO HOLD THE USER INPUT

       String text = input.nextLine();

       

       //The variable holder will be used to store characters from the for loop

       String holder="";

       

       //Create a for loop that loops through the user's input

       for(int i=0; i<text.length(); i++){

           //As the loop increases, we get the character in the user's input and store them one by one in the variable holder

           holder+=text.charAt(i);

           if(text.charAt(i)==' '){

               //If the loop encounters a space, it means a complete word has been gotten from the user's input

               //Then the break below Breaks the loop, and the loop stops running

               break;

           }

       }

       System.out.println(holder);

}

Explanation:

text.length() returns the length of the sequence of characters present in length

text.charAt(a number) Returns the char value at the specified index. An index ranges from 0 to length() - 1. The first char value of the sequence is at index 0, the next at index 1, and so on, as for array indexing.

Create a for loop

How does a for loop work?

It collects a starting point, an end point and an increment respectively....all these are passed in as arguments into the for loop

For example, the code above starts from 0, calculates the number of characters in the user's input and sets it as the end point, the loop runs from zero to the length of the text of the user...

Note: i++ in the loop is the increment, it means the loop increases by 1

8 0
3 years ago
This is an example of what type of formula?
Dimas [21]

Answer:

Subtraction

Explanation:

That is subtracting the values of two cells.

You know because of the "-" sign

4 0
2 years ago
What are the names of first generation computers?
KengaRu [80]
EDSAC is the first computer ever
8 0
3 years ago
Other questions:
  • Given the commands below, what do they do? for (position = 1 through aList.getLength()/2) { a = aList.getEntry(aList.getLength()
    11·1 answer
  • What occurs when you call a method on a reference variable that contains null? Select one: a. An ArrayIndexOutOfBoundsException
    11·1 answer
  • A search engine is aprogram to search......<br>​
    7·1 answer
  • What is a win-win situation?
    5·1 answer
  • Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per li
    11·1 answer
  • Why is know app downloading in my android phone even if I have 900 MB ???
    8·2 answers
  • Return a version of the given string, where for every star (*) in the string the star and the chars immediately to its left and
    11·1 answer
  • Are you allowed to copy and paste answers on brainy to give answers to other people?
    5·2 answers
  • The process of bringing data or a file from one program to another is called
    5·2 answers
  • What is a word processing program? Give examples of word processing programs.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!