CS 178 Programming with Multimedia Objects
Fall 2004 |
|||||||
In-class Programming Competition
Heats: Each group: 20 minutes. Final: 2 teams: 10 minutes Present your solution to the class on the chalkboard. 1 winner to be decided based on the best solution. Prepared by: Aditya Mathur. November 22, 2004. |
|||||||
Given the following global declarations: int maxEntries=100; String [] name=new String[maxEntries]; String [] list=new String[maxEntries]; boolean [] diff=new boolean[maxEntries]; int numEntries; // Number of entries in names and list. You are required to write a method that has the following signature: public boolean areTheySame() The areTheySame() method does the following: 1. It sets diff[i] to true if name[i] is the same as list[i]. 2. It returns true if entries in name are identiical to the corresponding entries in list; else it returns false. Example 1: Suppose that names={"jupitor", "mars", "earth"} and list={"jupitor", "earth", "mars"} then the areTheySame () method must set the diff array to diff={true, false, false} and return false. Example 2: Suppose that names={"biology", "math", "physics"} and list={"biology", "math", "physics"} then the areTheySame () method must set the diff array to diff={true, true, true} and return true. |
|||||||
Last update: November 22, 2004 |
|||||||