Question: A pure infinitely - repeating decimal number is defined as a decimal where all digits in the fractional part are non - zero and repeat
A pure infinitelyrepeating decimal number is defined as a decimal where all digits in the fractional part are nonzero and
repeat infinitely. For example, represents a pure infinitelyrepeating decimal number with the repeating sequence
Conversely, is not a pure infinitelyrepeating decimal number as it contains nonrepeating digits in its
fractional part. In this problem, it is assumed that all decimal numbers provided are pure infinitelyrepeating. Please write a
program to compute the sum of two pure infinitelyrepeating decimal numbers.
Input Format Please use java.util.Scanner to read the input.
The first line is an integer n indicating the number of test cases. Each test case consists of two pure infinitelyrepeating
decimal numbers x and y Both x and y may be positive. For example, indicates ; indicates
Output Format
For each test case consisting of pure infinitelyrepeating decimal numbers x and y print the sum of x and y
Note that your output may either a pure infinitelyrepeating decimal number or an integer. Even though and
are numerically equal, the former is not allowed. For your program should output an integer, rather than a
decimal.
Each test case consists of two decimal numbers x and y from Sample Input and Output
Sample Input and Output
API:
double java.lang.Double.parseDoubleString s
String java.lang.Double.toStringdouble d
String java.lang.String.substringint beginIndex
double java.lang.Math.powdouble a double b
long java.lang.Math.rounddouble a
String java.lang.String.formatString format, Object... args
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
