Question: Write a static method called sum _ abs that keeps prompting the user for integer values. Calculate the sum of the absolute values of all

Write a static method called sum_abs that keeps prompting the user for integer values. Calculate the sum of the absolute values of all the numbers entered without using any built-in methods. If the input number is negative, then add its positive value to the sum. If the input number is positive, then add it to the sum directly. Return the sum when the user enters 0. save your code in problem1.java. (20 pts) Test case: if the input stream is 10,-20,30,-40,50, and 0 sum_abs() returns 150(because 10+20+30+40+50=150).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!