Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this assignment has 100 points please help me and please it should be object oriented program format In this assignment, you will demonstrate your understanding

this assignment has 100 points please help me and please it should be object oriented program format
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
In this assignment, you will demonstrate your understanding of array and file operation in an object-oriented program. Non-OOP implementation receives 0 point. First download the file, USPopulateion.txt, in the drop box with the lab description. The file contains the population of the United States, in thousands, during the years 1950 through 1990. The first line in the file contains the population for 1950 , the second line contains the population for 1951 , and so forth. Write a program which reads data from an external file into an array, and then manipulates the data and displays following data: - The average annual change (not total population) in population during the entire period - The year with the greatest increase in population during the entire period - The year with the smallest increase in population during the entire period - The population in a specific year - A list of population during the specific period Please follow the following steps to complete the assignment: 1. Define a service class. The class should contain: - An array as a private data member in the data type, double - A constructor with an array object as a parameter, which is used instantiate the data member - Default constructor, mutator and accessor are optional - FOUR methods (each MUST return a value) to return first FOUR values (listed in the problem description above) for display. - A method to display or return population in a specific period (each void or return) - Other methods as needed Notes/hints: Some methods are like code on P436 (Grader. java) and P431 (SalesData.java). But need to do a little more complicate arithmetical operations, for example, to get an increase each year, and average of increase, and so on. The service class should work for manipulating data in ANY period (NOT just for 1950 - 1990). That means the class works on an array with ANY size. About parameter(s) for each method: The array is a private member. Do you need to pass an array to any of the methods as a parameter? Why? Why not? Is there any other parameter for any method? - What should be returned? A method can return any primitive data or object (including array) - In a service class, besides the data member specified in this lab description, you could have more data members as needed, but these members should be used to stored RAW data and used by multiple methods; otherwise keep variables as local (inside a method) as possible. - DO NOT RECALCULATE a value in more than one method. You can define other private or public methods to help the required methods. Always try to make a method to perform a single/small task. - How can you get a change comparing to the previous year? Remember to use index! For example, if the array called population, in the loop, population[i] represents population in a year, and population [i+1] is the next year. 2. Create an application class which uses the service class. Do the following step by step: - Create an array to hold data from year 1950 to 1990 (Size is 41). Do not need an array to hold years. - To keep track of years, you can use years given to set up starting year and ending year as constants, for example, if a starting year is 1950 , when you work with array, you can add an index value to get a year. If the starting year is 1950, the index 0 represents 1950 , and index 40 is 1990. Read data from the external file and store data in the array. Notes: - Need to review File IO in Module 4. One example for file input is FileReadDemo. java in Module 4 Code Examples. - Write "throws IOException" in the main() method header when 2 CTP 150 Computer Science 1 working with file IO. - To store data in the array, in the loop, read data form the file, and initialize each element in the array with read data. - Create an object of the Population class and pass the array object as the argument to the constructor. working with file IO. - To store data in the array, in the loop, read data form the file, and initialize each element in the array with read data. - Create an object of the Population class and pass the array object as the argument to the constructor. - Use the object to invoke methods in the service class display results, and search data. - For searching population in a year, use a loop to let user determine to continue or stop. If you have the optional method complete, do the loop too. 3. Test your program: Here is the running result: In population from 1950 through 1990 The number of year: 41 The average annual change was 2,443.88 The year with the greatest increase was 1955. The population was 165069 thousands. The year with the smallest increase was 1967. The population was 197457 thousands. Please enter a year you are looking for: 1988 Population in the year 1988 is 244499 thousands. Do you want to continue searching? (y):y Please enter a year you are looking for: 1967 Population in the year 1967 is 197457 thousands. Do you want to continue searching? (y):n Search populations in a specific period: Please enter starting year: 1961 Please enter ending year: 1970 The population in thousands from 1961 through 1970: Do you want to continue searching? (y):n

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_2

Step: 3

blur-text-image_3

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

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions