* The method fun will sum all the values except H for the multiples of 5 unless
ID: 3754677 • Letter: #
Question
* The method fun will sum all the values except H for the multiples of 5 unless it is a multiple of 100. public static int fun (int [] mary) ( return 0 public static void main (Stringt args) //client code int[l bob - (13, 27. 45, 93, 100, 425, 300, 205) System.out printin( Arrays.toString ( bob ) System.out-printin Sum tun ( bob )a 533 System.out.printin 21 23 25 26 27 28 29 30 int[1 ted (115,1200,1350,4121, 5237. 6445, 7600) System.out-printin ( Arrays.toString ted) D System.out printin( Sum fun( ted ?://181se System.out printin OF int [i sue(170, 211,365, 427, 500, 600,791) System.out.printin(Arays.toString ( sue)) System . out .printin ( "Sum = " + run ( sue ) );//2S2 9 32 General Output Configuration: Default> Conaand CProgran Files (x86)Javaidk1.8.0 131NbinNjava exel Helaaspas DirectoryH: Java AP CS 2ARRAYS LAB Build Output 1:a Task View General OutputExplanation / Answer
Please give a Thumps Up if you like tha answer
Program
import java.util.Arrays;
public class Sumofstringarray {
public static void main(String[] args)
{
int[] bob={13,27,45,93,100,425,300,205};
System.out.println(Arrays.toString(bob));
System.out.println("Sum = "+fun(bob));
System.out.println();
int[] ted={115,1200,1350,4121,5237,6445,7600};
System.out.println(Arrays.toString(ted));
System.out.println("Sum = "+fun(ted));
System.out.println();
int[] sue={170,211,365,427,500,600,791};
System.out.println(Arrays.toString(sue));
System.out.println("Sum = "+fun(sue));
System.out.println();
}
public static int fun(int[] mary)
{
int sum=0;
for(int i=0;i<mary.length;i++)
{
if((mary[i]%5!=0)||(mary[i]%100==0))
{
sum+=mary[i];
}
}
return sum;
}
}
Output
[13, 27, 45, 93, 100, 425, 300, 205]
Sum = 533
[115, 1200, 1350, 4121, 5237, 6445, 7600]
Sum = 18158
[170, 211, 365, 427, 500, 600, 791]
Sum = 2529
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.