Question: write a Java program that splits a text and computes the sum of values. Your program reads a single text from the user. The

write a Java program that splits a text and computes the sum of values. Your program reads a single text from

write a Java program that splits a text and computes the sum of values. Your program reads a single text from the user. The text consists of string representation of decimals that are split by '-' symbol and it is in the following format 12-13-45-2-560-...-4-234. The program will split the given text into string decimals and obtain integer values (you can use Integer.parseInt(str) ). It computes the sum of odd numbers and the sum of even numbers. At this point, you are expected to write a method called isEven, which gets a single integer as parameter and returns true if the number is even and false otherwise. Use this method as a helper method as you compute sums whenever you think is appropriate to call. For instance, the text entered by the user is 20-30-400-1-13-10, then the program returns 460 (-20+30+400+10) as the sum of even numbers 14 (=1+13) as the sum of odd numbers Sample outputs of the program must look like as below: Enter Text:78562-3456 Sum of Even: 82018 Sum of Odd:0 Enter Text: 23-40-3 Sum of Even: 40 Sum of Odd: 26 Enter Text:1-1-1-10-20-1-0-6-3-3 Sum of Even: 36 Sum of Odd:10 Enter Text:20-30-400-1-13-10 Sum of Even: 460 Sum of Odd:14 Activate W Go to Settings

Step by Step Solution

3.34 Rating (148 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Our experts were un... View full answer

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!