Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The XYZ daycare has installed a new high-tech system for keeping track of which children are under its supervision at any moment in time. Each
The XYZ daycare has installed a new high-tech system for keeping track of which children are under its supervision at any moment in time. Each parent of a child has a card with a unique ID, where the ID is some integer x. Every morning, the parent swipes the card at a card-reader when dropping their child off at the daycare. The system then adds x to an array of integers. In the evening, when the parent comes to pick up the child, the same card is swiped, and a second copy of x is added to the list. Each night at midnight, the array is wiped clean and reset to have zero elements. In this way, the daycare can quickly check every afternoon which children are yet to be picked up by their parents by picking out the array elements that occur precisely once. Unfortunately, at 4:55 pm on Thursday, April 20, 2017, the daycare realizes that somewhere in their daycare is precisely one child who is yet to be picked up. Can you help them determine the integer ID of this child?
Requirements: 1. The file name must be named as Problem2.java 2. Write a static method as specified in the following method header public static int checkIDs(int[] idMapping) This method accepts an int array as its parameter. If a number(child ID) appears twice in the array, that means the child with that ID was picked up by parents. It is guaranteed that precisely one child who is yet to be picked up. So this method should find and return that number. You may test your method with the following arrays int[] data1={1, 3, 3, 7,1,8,8} and checkIDs(data1) should return 7 int[] data2={10, 3, 3,20, 7,1,7,10,8,8, 1} and checkIDs(data2) should return 20
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started