Write a public static method named printArray, that takes two arguments. The first argument is an Array of int and the second argument is a String. The method should print out a list of the values in the array, each separated by the value of the second argument. For example, given the following Array declaration and instantiation: int[] myArray = {1, 22, 333, 400, 5005, 9}; printArray(myArray, ", ") will print out 1, 22, 333, 400, 5005, 9 printArray(myArray, " - ") will print out 1 - 22 - 333 - 400 - 5005 - 9 You may wish to write some additional code to test your method. -------------------------------------------------- // import any necessary packages here below public class Main {    public static void main(String[] args) {       // write any code to test you method(s) here below           }        // define your method(s) here below         }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Write a public static method named printArray, that takes two arguments. The first argument is an Array of int and the second argument is a String. The method should print out a list of the values in the array, each separated by the value of the second argument.

For example, given the following Array declaration and instantiation:

int[] myArray = {1, 22, 333, 400, 5005, 9};

printArray(myArray, ", ") will print out 1, 22, 333, 400, 5005, 9
printArray(myArray, " - ") will print out 1 - 22 - 333 - 400 - 5005 - 9

You may wish to write some additional code to test your method.

--------------------------------------------------

// import any necessary packages here below

public class Main {
   public static void main(String[] args) {
      // write any code to test you method(s) here below
      
   }
   
   // define your method(s) here below
   
   
}

Main.java
Load default template...
1 // import any necessary packages here below
2
3 public class Main {
public static void main(String[] args) {
// write any code to test you method(s) here below
int] myArray
}
4
6.
{1, 22, 333, 400, 5005, 9};
7
8
public static void printArray(int myarr[], String s){
for(int i = 0; i< myarr.length ;i++){
System.out.print(myarr[i]+s);
}
}
9.
10
11
12
13
14
15 }
When done developing your program, press the Submit for grading button below. This will
submit your program for auto-grading.
Develop mode
Submit mode
Submit for grading
Coding trail of your work
What is this?
3/27 U-40,40,40,40,40,0,40,40 min:6
Latest submission - 2:28 PM MST on 03/27/22
Total score: 40 / 100
Only show failing tests
Download this submission
1: Structure Test a
40 / 40
Transcribed Image Text:Main.java Load default template... 1 // import any necessary packages here below 2 3 public class Main { public static void main(String[] args) { // write any code to test you method(s) here below int] myArray } 4 6. {1, 22, 333, 400, 5005, 9}; 7 8 public static void printArray(int myarr[], String s){ for(int i = 0; i< myarr.length ;i++){ System.out.print(myarr[i]+s); } } 9. 10 11 12 13 14 15 } When done developing your program, press the Submit for grading button below. This will submit your program for auto-grading. Develop mode Submit mode Submit for grading Coding trail of your work What is this? 3/27 U-40,40,40,40,40,0,40,40 min:6 Latest submission - 2:28 PM MST on 03/27/22 Total score: 40 / 100 Only show failing tests Download this submission 1: Structure Test a 40 / 40
Latest submission - 2:28 PM MST on 03/27/22
Total score: 40 / 100
Only show failing tests
Download this submission
1: Structure Test a
40 / 40
Test feedback
PASS
public static void printArray(int[],String) method found.
2: Logic test 1 ^
0/ 30
printArray(myArray, ", ")` should print out `1, 22, 333, 400, 5005, 9`
FAIL
incorrect output
expected :
1, 22, 333, 400, 5005, 9
Test feedback
but got
:
1, 22, 333, 400, 5005, 9,
3: Logic test 2 ^
0/30
"printArray(myArray, " - ")` should print out `1 - 22 - 333 - 400 - 5005 - 9`
II
FAIL
incorrect output
expected :
1
22
333
400
5005
Test feedback
but got
:
1
22
333
400 -
5005
-
Transcribed Image Text:Latest submission - 2:28 PM MST on 03/27/22 Total score: 40 / 100 Only show failing tests Download this submission 1: Structure Test a 40 / 40 Test feedback PASS public static void printArray(int[],String) method found. 2: Logic test 1 ^ 0/ 30 printArray(myArray, ", ")` should print out `1, 22, 333, 400, 5005, 9` FAIL incorrect output expected : 1, 22, 333, 400, 5005, 9 Test feedback but got : 1, 22, 333, 400, 5005, 9, 3: Logic test 2 ^ 0/30 "printArray(myArray, " - ")` should print out `1 - 22 - 333 - 400 - 5005 - 9` II FAIL incorrect output expected : 1 22 333 400 5005 Test feedback but got : 1 22 333 400 - 5005 -
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY