Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

Heres a Java program that fulfills your requirements java import javautilScanner public cla... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions

Question

People born and bred in Wiltshire are known as Moonrakers. Why?

Answered: 1 week ago

Question

Case : Karl and June Monroe

Answered: 1 week ago