Write three (3) complete Java programs named, Happiness Report.java, Country.java and LevelList.java. Use the instructions given...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
Hi mate as per Homework Helps privacy policy experts are allowed to answer only one question or one ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these computer network questions
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Use implicit differentiation to find dy/dx. 6x 3 + 7y 3 = 13xy
-
What two organizations provide guidelines for reporting pension fund activities to stockholders? Describe briefly how pension fund data are reported in a firm's financial statements. (Hint: consider...
-
Produce use case diagrams and a set of associated sequence diagrams for the University Accommodation Office case study documented in Appendix B.1.
-
Melissa Khan alleges that on May 27, 2004, she entered into a lease and warranty agreement with Riverbank Motors Corporation, Inc. (the Dealership), for a new, 2004 Volkswagen Toureg (the Vehicle),...
-
Wells Technical Institute (WTI), a school owned by Tristana Wells, provides training to individuals who pay tuition directly to the school. WTI also offers training to groups in off-site locations....
-
MATH 114 MATH 114 ENERGY YEARLY PROJECTIONS USING ELECTRICITY, COAL, AND OIL PROJECT ASSIGNMENT INSTRUCTIONS OVERVIEW Ever wonder how your electricity bill is computed? The following tables gives the...
-
On January 1, 2016, Theta Corp. acquired a four unit apartment building at as cost of $1,475,000. Of this total, it is estimated that the land on which the building is situated is worth $250,000 and...
-
Write a report on any topic of any branch of biotechnology that IT can help?
-
Describe the role of fixed income markets in the " Great Recession" of 2008-9. In your answer be sure to identify: the role and design of collaterized mortgage obligations; the relevance of previous...
-
There is a penalty for underpayment of taxes if the total of combined withholding and estimated tax payments does not equal 90% of the tax shown on the current return, or: 90% of the tax paid in the...
-
A bond has a face (nominal) value $1,000 with an annual coupon rate of 10%. The bond will mature in 20 years, and the market's required return on similar bonds is 12%. Required: (i) Compute the price...
-
1. Month-end payments of $1,530 are made to settle a loan of $149,540 in 9 years. What is the effective interest rate? Round to two decimal places 2. Alexis wants to accumulate at least $50,000 by...
-
Assume that you acquire a (net) debt-free company for $1,000.00 with 65% of the acquisition financing (i.e., purchase price) coming from debt borrowings. You have created a five-year plan to use all...
-
The books of Cheyenne Corporation carried the following account balances as of December 31, 2020. The information below pertains to Sheffield Company for 2021. Net income for the year $1,160,000 7%...
-
Cornell and Roberts are partners who agree to admit Stanley to their partnership. Cornell has a capital balance of $80,000 and Roberts has a capital balance of $120,000. Cornell and Roberts share net...
-
In 2012, Michael has net short-term capital losses of $2,000, a net long-term capital loss of $45,000, and other ordinary taxable income of $45,000. a. Calculate the amount of Michael's deduction for...
-
Tom has a successful business with $100,000 of income in 2012. He purchases one new asset in 2012, a new machine which is 7-year MACRS property and costs $25,000. If you are Tom's tax advisor, how...
-
John Fuji (age 37) moved from California to Washington in December 2011. He lives at 468 Cameo Street, Yakima, WA 98901. John's Social Security number is 571-78-5974 and he is single. His earnings...
-
The basketball player from Example 2 is asked to shoot three free throws 100 times. Compute the mean number of free throws made. Approach The player shoots three free throws and the number made is...
-
A term life insurance policy will pay a beneficiary a certain sum of money upon the death of the policyholder. These policies have premiums that must be paid annually. Suppose an 18- year-old male...
-
Find the standard deviation of the discrete random variable given in Table 1 from Example 2. Approach We will use Formula (2a) with the unrounded mean X = 2.39. Approach We will use Formula (2b)...
Study smarter with the SolutionInn App