DPIT121 – Lab Exercise 5 Due: Week 7 lab In lab 5, you will continue on another iteration focusing on HashMap as a Data Structure and for Data Aggregation, and Exception Handling. Download and study...

1 answer below »
HI this is my lab exercise 5 which is continue part of lab 1,2,3,4 and assignment 1 you guys did all these parts for me as we discussed before this is complete chain of assignments related to each other kindly do this for me if you need my details in assignment which isSTUDENT NAME: AHMER NASIR
STUDENT ID: 6880101STUDENT MAIL: [email protected]


DPIT121 – Lab Exercise 5 Due: Week 7 lab In lab 5, you will continue on another iteration focusing on HashMap as a Data Structure and for Data Aggregation, and Exception Handling. Download and study lecture codes from week 5. Also, study Lab 2 Solution from “Sample labs 4-6 and Solutions” folder which is similar to this lab. 1) Comment the ArrayList of plans in the User class and users in the MobileCompany and replace it with HashMaps. The HashMap key is the planID and userID and the value is the corresponding plan and user, respectively. Don’t remove any codes and methods but comment the old code and modify your code/methods to be compatible with HashMaps as below: - Comment the old code and modify the addPlan, findPlan, addUser, and findUser for Hashmap instead of ArrayList. - Keep all the static methods: print, filter, calcTotalPayment, and mobilePriceRiseAll for ArrayList inside the MobilePlan class but add new methods with the same names but for a HashMap of plans. - Comment the old code for print, filter, calcTotalPayment, and priceRiseAll for ArrayList inside the User class and modify them for the new static methods inside MobilePlan working with HashMap. You also need to modify toString(), copy constructor, and clone() methods. - Comment the old code for any methods inside the InsuranceCompany working with ArrayList and modify it for the HashMap. - keep the old static shallow and deep copy methods of ArrayList inside the MobilePlan but add these methods to MobilePlan: ArrayList< mobileplan>  shallowCopy (HashMap< integer, mobileplan =""> plans)  ArrayList< mobileplan>  deepCopy (HashMap< integer, mobileplan =""> plans)  HashMap< integer, mobileplan =""> shallowCopyHashMap (HashMap< integer, mobileplan =""> plans)  HashMap< integer, mobileplan =""> deepCopyHashMap (HashMap< integer, mobileplan =""> plans)  - Comment the old code for shallow copy and deep copy methods inside the User and MobileCompany and modify them to work with HashMaps. Note that these methods still should return an ArrayList of plans and users. Add new versions of these methods to return HashMaps of plans and users. - The sort methods inside the User and MobileCompnay still should return an ArrayList as HashMap is not sortable. Comment the old code and modify it to make a shallow copy of plan and user HashMaps to ArrayLists first, and then sort the ArrayList and return it. 2) For data aggregation reports by using HashMap add following methods to the class User: HashMap getTotalCountPerMobileModel () // which aggregates the number of plans the user owns for any given mobile model as and returns the hashmap. HashMap getTotalPaymentPerMobileModel () // which aggregates the total monthly payments of plans the user owns for any given mobile model as a a list of pairs of and returns the HashMap - Add proper report methods to the class User to generate this report from the aggregated hashmaps: Mobile ModelTotal Monthly PaymentAverage Monthly Payment Iphone X $1,050.00 $105.00 Samsung Galaxy 10 $425.00 $85.00 (Assume this user has ten plans with the Mobile Model of “Iphone X” and five with Samsung Galaxy 10) 3- For data aggregation reports add following methods to the class MobileCompany: HashMap getTotalPaymentPerCity() // which aggregates the total monthly payments for users from any given city within the company as e.g., we have three users from Wollongong, two from Sydney, etc HashMap getTotalCountPerMobileModel () // returns a list of pairs of (Mobile Model, Count) as a HashMap across all the users within the company (by calling the corresponding method inside User) HashMap getTotalPaymentPerMobileModel () // returns a list of pairs of (Mobile Model, Total Monthly Payments) as a HashMap across all the users within the company (by calling the corresponding method inside User) - Add proper report methods to the class MobileCompany to generate these reports from the aggregated hashmaps: City Name Total Monthly Payments Wollongong $10,500.00 Sydney $45,980.00 Assuming that there are 110 users with the city=”Wollongong” and the total of monthly payments for all of their plans is $10,500 And the same as 2 but across all users: Mobile ModelTotal Monthly PaymentAverage Monthly Payment Iphone X $10,500.00 $105.00 Samsung Galaxy 10 $15,300.00 $51.00 4) Add try catch to any section of the code that the program uses Scanner to read from the console and catch the InputMismatchException to catch any wrong input (e.g., String entry for a number) and prompt user. Keep asking user to enter the proper data. Your program should not stop/crash but to continue normally after the catch. In particular modify your UI option 2, 3, 4, and 8. If admin enters a wrong data (such as a string for street number or mobile price) prompt the admin to enter the correct data type and keep asking for the correct data without crashing (By using a while loop and a Boolean success flag the same as lecture code). 5) Let’s assume that Plan ID should be 6 digits starting with 3: - Add a new Exception Class PlanException with one field: int ID. - In the Plan constructor if the given ID does not follow the required pattern: - Generate a random ID with the given pattern 3xxxxxx - Throw a PlanException by passing the generated ID as an argument to PlanException constructor. - The toString() method in PlanException creates an error message “ The Plan ID was not valid and a new ID (the generated ID) is generated by admin and assigned for the Plan”. In your UI option 3 and 4 catch this exception and print it. Again your program should continue normally after catching this exception. You need to create the Personal or Business Plan with the user information but the generated ID and add it to the user plans. 6) Modify your test code for the modified code in this lab in particular calling all the data aggregation methods. 7) Add following options to your basic UI: - Option 9 to report Mobile Model, Total Monthly Payment, and Average Monthly Payment for a given user - Option 10 to report City Name, Total Monthly Payments across all users - Option 11 to report Mobile Model, Total Monthly Payment, and Average Monthly Payment across all users
Answered 2 days AfterApr 20, 2021

Answer To: DPIT121 – Lab Exercise 5 Due: Week 7 lab In lab 5, you will continue on another iteration focusing...

Rushendra answered on Apr 22 2021
143 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here