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 Output
0 0
Add a comment Improve this question Transcribed image text
Answer #1

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

Add a comment
Know the answer?
Add Answer to:
* The method fun will sum all the values except H for the multiples of 5...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT