Question: Done in Java. Any help is appreciated. Here is what I have so far: import java.util.Scanner; // class begin public class Lab3Exercises { // receives

Done in Java. Any help is appreciated.

Done in Java. Any help is appreciated. Here is what I have

Here is what I have so far:

import java.util.Scanner;

// class begin public class Lab3Exercises { // receives int from userInt in main // only keep last 3 digits of number entered // reverse these digits // subtract original input from reversed (discard minus sign if negative) // reverse digits of difference // add difference and reversed difference // return sum (should be finally printed in main) // for smaller numbers assume preceding zeros // assume only positive integers are the inputs // ignore palindrome inputs (ex. 404, 515) // write appropriate JUnit tests public static int my1089Puzzle(int myInput) { //return int; } public static void main(String[] args) { // Scanner for my1089Puzzle Scanner userInt = new Scanner(System.in); int puzzle = userInt.nextInt(); my1089Puzzle(puzzle); } }

1. Create a class named Lab3Exercises and Implement the following static methods (we will not use this class to instantiate objects) and write JUnit tests when asked: a) public static int my1089Puzzle (int myInput) i. Implement a function that receives an integer from user (in main method) and does the following: Discard all but last 3 digits. Reverse these digits, subtract the original (input) from the reversed (discarding any minus sign), reverse the digits of the difference, and add the difference and the reversed difference. Then return the sum (which should be printed in main). For examples: Input: 371 Reversed: 173 Difference: 198 Reversed: 891 Sum: 1089 For smaller numbers, assume preceding zeros. Few things to remember: Assume only positive integers are the inputs. You can ignore palindrome inputs which return a value of O for difference. For ex., 404. May be return-1. If you get numbers less than 100 after reversal, you should be adding leading zeroes. For ex., 2 should be 002, 99 should be 099. ii. Use the Scanner class to get input from the user (in main method) and pass that as a parameter to the method above. Get the returned value and print it along with the user input. iii. After thorough testing, Write appropriate JUnit tests. 1. Create a class named Lab3Exercises and Implement the following static methods (we will not use this class to instantiate objects) and write JUnit tests when asked: a) public static int my1089Puzzle (int myInput) i. Implement a function that receives an integer from user (in main method) and does the following: Discard all but last 3 digits. Reverse these digits, subtract the original (input) from the reversed (discarding any minus sign), reverse the digits of the difference, and add the difference and the reversed difference. Then return the sum (which should be printed in main). For examples: Input: 371 Reversed: 173 Difference: 198 Reversed: 891 Sum: 1089 For smaller numbers, assume preceding zeros. Few things to remember: Assume only positive integers are the inputs. You can ignore palindrome inputs which return a value of O for difference. For ex., 404. May be return-1. If you get numbers less than 100 after reversal, you should be adding leading zeroes. For ex., 2 should be 002, 99 should be 099. ii. Use the Scanner class to get input from the user (in main method) and pass that as a parameter to the method above. Get the returned value and print it along with the user input. iii. After thorough testing, Write appropriate JUnit tests

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!