Арг 4 min C 0 9 8 C:\Users\Cristian\Documents\CIS2830\Assignments\PROG20\starter.java.- Sublime Text (UNREGISTERED) File

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Арг 4 min C 0 9 8 C:\Users\Cristian\Documents\CIS2830\Assignments\PROG20\starter.java.- Sublime Text (UNREGISTERED) File

Post by answerhappygod »

 1
1 (52.77 KiB) Viewed 46 times
Арг 4 min C 0 9 8 C:\Users\Cristian\Documents\CIS2830\Assignments\PROG20\starter.java.- Sublime Text (UNREGISTERED) File Edit Selection Find View Goto Tools Project Preferences Help ||| BankFees.java | Gradesjava x | CountVowels.java EnterANumberBetween5And 10.java x 1 1 import java.util.*; 2 public class AddAllElements { 3 //readArray reads an array of ints from the user 5 public static int [] readArray(){ 6 String ss = input.nextLine(); 7 String [] aa = ss.split("[, ]"); int [] int_array = new int[aa. length]; 9 if(aa[@].length() 0){ 10 int_array = new int[@]; 11 return int_array; 12 } 13 int ii = 0; 14 for (String str : aa) { 15 int_array[ii++] = Integer.parseInt(str); 16 } 17 return int_array; 18 } 19 20 //#######your code starts here. //write method called addAllElements that takes one array of ints 1/and returns the sum of all the elements of the array 23 //do not alter the starter anywhere outside of this area 24 25 26 // #your code ends here 27 نزن 21 22 28 static Scanner input = new Scanner(System.in); public static void main (String[] args) { int result 0; //readArray reads an array from the user int [] myArray readArray(); = 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 //the following line calls the method you are supposed to write result addAllElements(myArray); System.out.println("result: + result); } }
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply