Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Country 1/-------Start below here. To do: approximate lines of code = 14 * Create 3 instance variables: one of type String to store

image text in transcribed

image text in transcribed

image text in transcribed

public class Country 1/-------Start below here. To do: approximate lines of code = 14 * Create 3 instance variables: one of type String to store the * country name, one of type int to store the population and one of * type double to store the 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 Create a public method getCountryStats() that returns a String containing the name of the country followed by the population followed by the area. See the tester code as a guide. Create a public method get PopulationDensity) that returns a double number representing the population density. Make sure to check that area is a before dividing population by it public class CountryTester public static void main(String[] args) Country canada = new Country("Canada", 35000000, 9985000); Country france = new Country("France", 66000000, 643800); // Expected Output: 1/ Name: Canada Population 35000000 Area 9985000.0 Density 3.5052578868302455 // Name: France Population 66000000 Area 643800.0 Density 102.51630941286113 System.out.println("" + canada.getCountryStats() + " Density " + canada.getPopulationDensity(); System.out.println(" + france.getCountryStats() + " Density " + france.getPopulationDensity()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

please dont use chat gpt or other AI 5 4 5 . .

Answered: 1 week ago