Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a method that sums every second digit, right to left. * If doubling results in a double-digit, * add up the digits to produce

Write a method that sums every second digit, right to left.

* If doubling results in a double-digit,

* add up the digits to produce a single.

* 4388576018402626 =>

* 2*2 = 4

* +2*2 = 4

* +2*4 = 8

* +2*1 = 2

* +2*6 = 12 => 3

* +2*5 = 10 => 1

* +2*8 = 16 => 7

* +2*4 = 8

* = 37

public static int sumOfDoubleEvens(String s) {

}

Here are the test cases that the code should cover.

_testSumOfDoubleEvens("", 0);

_testSumOfDoubleEvens("0", 0);

_testSumOfDoubleEvens("1", 0);

_testSumOfDoubleEvens("2", 0);

_testSumOfDoubleEvens("9", 0);

_testSumOfDoubleEvens("00", 0);

_testSumOfDoubleEvens("11", 2);

_testSumOfDoubleEvens("22", 4);

_testSumOfDoubleEvens("99", 9);

_testSumOfDoubleEvens("03", 0);

_testSumOfDoubleEvens("52", 1);

_testSumOfDoubleEvens("27", 4);

_testSumOfDoubleEvens("98", 9);

_testSumOfDoubleEvens("30", 6);

_testSumOfDoubleEvens("25", 4);

_testSumOfDoubleEvens("72", 5);

_testSumOfDoubleEvens("89", 7);

_testSumOfDoubleEvens("4388576018402626", 37);

_testSumOfDoubleEvens("5117275325077359", 18);

_testSumOfDoubleEvens("378282246310005", 27);

_testSumOfDoubleEvens("371449635398431", 47);

_testSumOfDoubleEvens("378734493671000", 32);

_testSumOfDoubleEvens("6011111111111117", 17);

_testSumOfDoubleEvens("5555555555554444", 22);

_testSumOfDoubleEvens("5105105105105100", 7);

_testSumOfDoubleEvens("4012888888881881", 47);

_testSumOfDoubleEvens("4222222222222", 24);

Please help with this I have my own code but I need to reference it to someone else's.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Database And Expert Systems Applications 23rd International Conference Dexa 2012 Vienna Austria September 2012 Proceedings Part 1 Lncs 7446

Authors: Stephen W. Liddle ,Klaus-Dieter Schewe ,A Min Tjoa ,Xiaofang Zhou

2012th Edition

3642325998, 978-3642325991

More Books

Students also viewed these Databases questions

Question

Differentiate Personnel Management and Human Resource Management

Answered: 1 week ago

Question

Describe the functions of Human resource management

Answered: 1 week ago

Question

What are the objectives of Human resource planning ?

Answered: 1 week ago

Question

Explain the process of Human Resource Planning.

Answered: 1 week ago