Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The CasesByCountry class has three instance variables, a three-parameter constructor, three get methods and one set method for the number of cases.The instance variables will

TheCasesByCountryclass has three instance variables, a three-parameter constructor, three get methods and one set method for the number of cases.The instance variables will hold the country, number of cases, and the population of the country.This class will be used in theCasesByCountryTestprogram.Do NOT modify the code in theCasesByCountryclass. I attached the CasesByCountry file screenshot below

I have to make a program named CasesByCountryTest

The test program will test theCasesByCountryclass by creatingCasesByCountryobjects that will be stored in an array.The program must do the following:

  • make an array namedcasesof typeCasesByCountrythat will hold 20CasesByCountryobjects.
  • EachCasesByCountryobject will be created with literal data for the 20 countries with the most confirmed cases of COVID-19. I mustget the data from this site on the day that you do the assignment:

https://coronavirus.jhu.edu/map.html(Links to an external site.)

Note that the population is taken from the United Nations 2019 data.

https://en.wikipedia.org/wiki/List_of_countries_by_population_(United_Nations)(Links to an external site.)

  • I must use theCasesByCountryconstructor to create each object using literal data as arguments. Store each object in thecases
  • Use a for loop to print a table of theCasesByCountrydata in the array. Be sure to print the table headers before the loop.Print the country, the number of cases, the population and the percentage of cases on each row.You must calculate the percentage of cases based on the number of cases and population.You can get help with percentages here:

https://www.khanacademy.org/math/pre-algebra/pre-algebra-ratios-rates/pre-algebra-percent-problems/v/finding-percentages-example(Links to an external site.)

  • All data in each row must be right aligned.Print the number of cases and the population with a comma.For example: "%,7d" will print 23,136.Print the percentage with 4 places past the decimal point.
  • make a for loop to go through the array to find the country with the highest percentage of cases. Print the country and the highest percentage, formatted and clearly labeled.note that my result will be different from the sample program run.
  • Use Sublime Text 3 or a simple editor for the program. Your name must appear in the output or one point will be deducted.all oyput must be carefully labeled
  • I'm also attaching the how output should look like and the sample output data is from April 3 so our output result will be different
    image text in transcribedimage text in transcribed
.. . CasesByCountry.java UNREGISTERED CasesByCountry.java x // CasesByCountry // MANDATORY COMMENTS MUST GO HERE public class CasesByCountry { // instance variables private String country; private int numberOfCases; private int population; // constructor public CasesByCountry(String country, int population, int numberOfCases) { this . country = country; if (numberOfCases > 0) // validate parameter this. numberOfCases = numberOfCases; if (population > 0) // validate parameter 18 this . population = population; 19 20 21 // return country 22 public String getCountry () { 23 return country; 24 25 // return number of cases 26 public int getNumberOfCases ( ) { return numberOfCases; 28 29 // return population public int getPopulation( ) { return population; 34 35 // update number of cases 36 37 public void setNumberOfCases (int numberOfCases) { 38 / validate parameter if ( numberOfCases > this. numberOfCases) 39 this . numberOfCases = numberOfCases; 40 41 42 43 Line 19, Column 1 Spaces: 3 JavaCOVID-19 Cases by Country Country I Cases Population Percentage US I 257,773 329, 064,917 0.0783 Spain I 117, 710 46, 736,776 0. 2519 Italy I 115,242 60,550, 075 0. 1903 Germany I 89,451 83, 517, 045 0. 1071 China I 82,509 1, 433, 783,686 0. 0058 France I 59,942 65, 129, 728 0. 0920 Iran I 53, 183 82, 913,906 0. 0641 United Kingdom I 38,688 67,530,172 0. 0573 Switzerland I 19,303 8, 591, 365 0.2247 Turkey I 18, 135 83,429,615 0. 0217 Belgium I 16,770 11, 539, 328 0. 1453 Netherlands I 15, 819 17, 097, 130 0. 0925 Canada I 11, 746 37, 411, 047 0. 0314 Austria I 11, 444 8,955, 102 0. 1278 South Korea I 10,062 51, 225, 308 0. 0196 Portugal I 9,886 10, 226, 187 0. 0967 Brazil | 8,195 211, 049,527 0. 0039 Israel I 7,030 8, 519,377 0. 0825 Sweden I 6,131 10, 036,379 0. 0611 Australia I 5,330 25, 203, 198 0. 0211 The country with the highest percentage of COVID-19 cases is Spain with 0.2519% Programmed by YOUR NAME

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

What is image and brand management?

Answered: 1 week ago