Question: IN JAVA 1 2 public class Province { 5 String name; int population; double area; /** Create a constructor method that has 3 parameters, one
IN JAVA


1 2 public class Province { 5 String name; int population; double area; /** Create a constructor method that has 3 parameters, one to initialize the name, one to initialize the population and one to initialize the area */ // -Start below here. To do: approximate lines of code = 4 // 1/ -End here. Please do not remove this comment. Reminder: no changes outside the todo regions. | 123456789BHBBHSBUBB%2284828B%HRB456 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 /** Create a public method called getProvinceStats() that returns a String containing the name of the province followed by " Population: followed by the population followed by " Area: " followed by the area */ 17 -Start below here. To do: approximate lines of code = 2 // --End here. Please do not remove this comment. Reminder: no changes outside the todo regions. /** Create a public method get PopulationDensity) that returns a double number representing the population density. */ -Start below here. To do: approximate lines of code = 2 // -End here. Please do not remove this comment. Reminder: no changes outside the todo regions. 47 48 49 50 51 52 53 // Create a public method int compareDensity (Province other) that returns // +1 if the this province density is > than the other province density // -1 if the this province density is 0) System.out.println("Ontario has a population density greater than PEI"); else if (ontario.compareDensity(pei) 0) System.out.println("Ontario has a population density less than PEI"); else System.out.println("Ontario has a population density equal to PEI"); System.out.println("Expected: Ontario has a population density less than PEI"); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
