Create a public class GenerationFinder with static method findGeneration and a s
ID: 3709904 • Letter: C
Question
Create a public class GenerationFinder with static method findGeneration and a static two-dimensional array containing information about five generations:
public static String findGeneration( int year )
The static two-dimensional String generations array will have five rows, and each row will contain information about one generation. Each row will have three columns containing the generation name, year range, and traits. Be sure to declare the array inside of the class but outside of any method.
Traditionalist 1900-1945
Competent, confident, conservative, ethical, hard-working, patriotic, respectful of authority, sacrifice, strong work ethic
Baby Boomer 1946-1964
Challenge authority, competitive, good communication skills, idealistic, multi-taskers, optimistic, political correctness
Generation X 1965-1980
Adaptable, confident, flexible, independent, self-starters, strong sense of entitlement, willing to take on responsibility
Millennial 1981-2000
At ease in teams, fiercely independent, innovative, loyal to peers, sociable, self-absorbed, sense of entitlement, tech-savvy
Generation Z 2001-2020
Independent, entrepreneurial, pragmatic about money, diverse, tolerant, global, risk-averse, technology is a way of life
The findGeneration method has an int parameter and returns a String that contains the Generation name, year range, and traits. If the parameter (birth year) is not in the range 1900-2020 the method should return a String containing “Not found”. Otherwise, it should return a String with the generation information from the array row.
Create a program GenerationFinderTest that prompts the user for a birth year 1900-2020, finds the generation and displays the info. Do the following in the GenerationFinderTest program:
Use a while loop to prompt for a birth year. Use nextInt to read in the year. If an invalid year is entered display the prompt again.
Call the findGeneration method and then display the generation info (String) returned by the method. Call the static method through the class name. For example: GenerationFinder.findGeneration(year)
The loop must keep executing until the user enters -1.
Use the command prompt window (terminal) for ALL input and output.
Your full name must appear in the output or 1 point will be deducted. You must follow the Programming Guidelines handout. All code must be correctly indented and commented. Your files must compile in order to be graded. Do NOT use Eclipse, NetBeans, or IntelliJ for any labs or assignments. Do NOT create packages or projects; otherwise I will not be able to grade your assignment.
Explanation / Answer
Hi Dear,
Please find my implementation.
Output:
Enter a birth year 1900-2000 to find your generation(-1 to quit): 1975
Generation X 1965-1980
Adaptable, confident, flexible, independent, self-starters, strong sense of entitlement, willing to take on responsibility
Enter a birth year 1900-2000 to find your generation(-1 to quit): 1991
Millennial 1981-2000
At ease in teams, fiercely independent, innovative, loyal to peers, sociable, self-absorbed, sense of entitlement, tech-savvy
Enter a birth year 1900-2000 to find your generation(-1 to quit): -1
Process finished with exit code 0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.