Question: Java Solution Please, thank you! Task You are given a positive integer consisting only of digits 6 and 9. Find the maximum value that can

 Java Solution Please, thank you! Task You are given a positive

Java Solution Please, thank you!

Task You are given a positive integer consisting only of digits 6 and 9. Find the maximum value that can be achieved by turning at most one digit upside down (6 becomes 9 and 9 becomes 6). For example, given integer 696: Turning the first digit upside down ( 6 9) would result in the number 996. Turning the second digit upside down ( 9 6) would result in the number 666. Turning the third digit upside down ( 6 9) would result in the number 699. The maximum value among 696, 996, 666 and 699 is 996. Write a function: int solution(int A); that, given an integer A, returns the maximum integer that can be achieved by turning upside down at most one digit in A. Examples: 1. Given integer 696, your function should return 996. The result is achieved by turning the first digit upside down. 2. Given integer 99, your function should return 99. The result is achieved by not turning any digit upside down. 3. Given integer 99666, your function should return 99966. The result is achieved by turning the third digit upside down. Assume that: A is an integer within the range [6..999,999,999); integer A contains only digits 6 and 9. In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment. Copyright 2009-2020 by Codility Limited. All Rights Reserved. Unauthorized copying, publication or disclosure prohibited

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 Databases Questions!