Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help me fix the problem with my code. import java.util.Scanner; public class Problem1 { public static int[] makeBigger(int[] arr, int n) { int[] newArr =

image text in transcribedimage text in transcribed

Help me fix the problem with my code.

import java.util.Scanner;

public class Problem1 {

public static int[] makeBigger(int[] arr, int n) {

int[] newArr = new int[arr.length + n];

for (int i = 0; i

newArr[i] = arr[i];

System.out.print(newArr[i] + " ");

}

for (int j = arr.length; j

System.out.print(newArr[j] + " ");

}

return newArr;

}

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int n = sc.nextInt();

int[] arr = new int[n];

for (int i = 0; i

arr[i] = sc.nextInt();

}

int x = sc.nextInt();

int[] result = makeBigger(arr, x);

System.out.print(result);

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

18. If you have power, then people will dislike and fear you.

Answered: 1 week ago