Question: Write three (3) complete Java programs named, Happiness Report.java, Country.java and LevelList.java. Use the instructions given in (a), (b) and (c). a) Define class
Write three (3) complete Java programs named, Happiness Report.java, Country.java and LevelList.java. Use the instructions given in (a), (b) and (c). a) Define class Country with the following information: (i) Class Country has 4 attributes: name, factor, index and category (ii) Write a constructor for class Country that initializes Country attributes through parameter passing. (iii) Write suitable code for the getter (accessor) methods. b) Write a class Level with the following information: (i) The class uses enum data type. The enum class has a fixed set of constants as listed in Table 1. Define the enum data type based on all levels listed in Table 1. (ii) Class Level has 2 attributes: index and category. (iii) Write a constructor for class Level that initializes Level attributes through parameter passing. (iv) Write suitable code for the getter (accessor) methods. Activ Go to S Table 1: Set of constant and values for Level enum class CATEGORY LEVEL LEVEL1 LEVEL2 LEVEL3 LEVEL4 INDEX 8.0 6.0 4.0 1.0 HIGH HAPPINESS MEDIUM HAPPINESS LOW HAPPINESS NOT HAPPY Write class Happiness Report that only has main() method with the following codes: Read an input file named InputSA.txt that contains of a list of level, name and factor of the Country. (1) (ii) Create an array of objects from class Country to store the value that read in c(i). (iii) Print all levels in the Level enum class to produce the output as in Figure 2. (iv) Count how many levels for High, Medium, Low and Not Happy. (Use enum value to count the different levels). (v) Count the number of all levels. (You may use static variable to count the total levels) (vi) The program should produce the output as shown in Figure 2. You need to use appropriate formatting for the output. (vii) In your program, you need to identify the suitable variables, instance declarations, and vector declaration where appropriate. Level1 Finland Environment Level2 Denmark Job Level4 Sudan Environment Level2 Norway Salary Level3 USA Environment Levell Ireland Salary Level3 Rwanda Environment Leve14 Bangladesh Population Level4 Myanmar Job Level4 India Population Level3 Thailand Environment Level3 Malaysia Job Leve 14 Indonesia Population Figure 1. Content of InputSA.txt Category of Happiness LEVEL1: 8.0 LEVEL2: 6.0 LEVEL3: 4.0 LEVEL4: 1.0 Level Factor 1 -600 WNT 2 4 9 10 11 12 13 Job HIGH HAPPINESS MEDIUM HAPPINESS Environment Job LOW HAPPINESS NOT HAPPY COUNTRY INDEX HAPPINEST Country Index Finland. 8.0 Denmark 6.0 1.0 6.0 4.0 8.0 Environment Salary Environment Salary Environment Population Job Population Environment Population Sudan Norway USA Ireland Rwanda Bangladesh Myanmar India Thailand Malaysia Indonesia Total in HIGH HAPPINESS Total in MEDIUM HAPPINESS Total in LOW HAPPINESS Total in NOT HAPPY Total Countries = 13 Press any key to continue = 2 2 = 4 5 = = 4.0 1.0 1.0 1.0 4.0 4.0 1.0 Output produced from question c(iii) REPORT Category HIGH HAPPINESS MEDIUM HAPPINESS NOT HAPPY MEDIUM HAPPINESS LOW HAPPINESS HIGH HAPPINESS LOW HAPPINESS NOT HAPPY NOT HAPPY NOT HAPPY LOW HAPPINESS LOW HAPPINESS NOT HAPPY Figure 2: Expected Output of the program
Step by Step Solution
3.40 Rating (156 Votes )
There are 3 Steps involved in it
Hi mate as per Homework Helps privacy policy experts are allowed to answer only one question or one ... View full answer
Get step-by-step solutions from verified subject matter experts
