Create a new Java Project in Eclipse

Assignment Help Computer Engineering
Reference no: EM132411274

CS520 Assignment -

You are strongly encouraged to add comments into your program!

Create a new Java Project in Eclipse named HW5_lastName and complete the following requirements.

Create a package named cs520.hw5. Using this package, create the following classes.

1. Create a class named Senator as follows.

a. The instance (or member) private variables - name, party, state (String), and yearsInOffice (integer).

b. A single constructor with name as its argument.

c. The public get and set methods for the instance variables.

d. Override the toString method to return the string representation of this object in the format "<name> (<party>) from <state> has been the senator for <yearsInOffice> years".

2. Create a SenatorTest class to test the following functionality in its main method.

a. Declare and initialize an empty Queue of Senator objects named senatorQueue.

b. Declare and initialize an empty HashMap named senatorMap.

The keys will be the names of the senators and the entries in the map will be the corresponding senator objects. c. Use the BufferedReader class to read the data.txt file. The contents of the file are shown below. Create the data.txt file in HW5_lastName.

d. Read the contents of the text file one line at a time using a loop. The program should work for any number of input lines. In this loop,

1. Invoke the processInputData method for each line read. This method returns the corresponding Senator object.

2. Add this Senator object to the senatorQueue.

3. Insert this Senator object into the senatorMap using the senator's name as the key.

e. After the loop is processed, do the following.

1. Iterate over the senatorQueue and display each element to the console.

2. Access the keys of the senatorMap and assign them to an appropriate variable. Create an iterator over the keys. Iterate over each key in this set and display the associated object in the map to the console.

Write a private method processInputData with return type Senator which processes its string input argument and returns the corresponding Senator object as follows.

1. Tokenize the string argument using the StringTokenizer class using the comma as the delimiter, or using the String split method.

2. Extract the name token. Create a Senator object and assign to the local variable currentSenator.

3. Read the rest of the tokens one token at a time. Use the corresponding set method on the currentSenator object to set the instance value.

4. If the yearsInOffice is not a valid number, i.e., throws an exception when parsed, set the value as -99 in the exception handling part.

5. The method should return the currentSenator object.

Attachment:- Assignment File.rar

Reference no: EM132411274

Questions Cloud

What treatment would you recommend and why : A family recently found out that their 8-year-old has ADHD and they are trying to decide which treatment course they should choose. Based on your research.
How to build a positive emotional climate in the classroom : Emotions play a large part in the learning process. Emotions impact how we learn and the information that we are able to retain. Our brains are highly.
Define how each study is consistent with biblical worldview : Discuss how each study is consistent/inconsistent with a biblical worldview, as well as how it might be of value to Christians in the real world.
Self-organize and identify the members of your Agile Team : Agile Team Composition. Self-organize and identify the members of your Agile Team, including roles
Create a new Java Project in Eclipse : CS520 Assignment - Create a new Java Project in Eclipse named HW5_lastName and complete the requirements - Create a class named Senator
Define moral reasoning and moral behavior : Your aunt and uncle are concerned about whether their teenage children, your cousins, will develop into moral adults. They ask you about adolescent moral.
What special issues of confidentiality may arise in the case : What special issues of confidentiality may arise in the case? How should David address these issues? How might differences in personal values and gender.
5DVP Developing Professional Practice Assignment : 5DVP Developing Professional Practice Assignment Help and Solution and The Effective HR Professional Assessment Writing Service - Describe a range of knowledge
Emerging issues in health care management : Emerging Issues in Health Care Management. Discuss the potential impact of the issue on a Specific health care organization.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Design a document containing plan for authentication methods

Design a document containing a sample plan for authentication methods, users, and roles used for a test database.

  Sector specific challenges in crafting security policy

Compare and contrast at least two U.S. Critical Infrastructure sector specific challenges in crafting security policy

  Explain whether this policy a good idea

Explain whether this policy a good idea? Explain on how it can be enforced?

  What is your practical experience with security protocols

What is your practical experience with Physical Security Protocols? In your current job, what are the physical security protocols that you are required.

  Write a high-level program for this computation using a fork

Consider the following computation: ci = ai*bi + ci*di where, i = 1 to N. Write a high-level program for this computation using a fork/join.

  Give a formal definition of the term deque

Give a formal definition of the term deque, using the definitions given for stack and queue as models.

  When does recursive is palindrome method stop calling itself

Do we have to give the same name to both is Palindrome methods? When does the recursive is Palindrome method stop calling itself?

  Make a program of a factorial function to calculate

Write a C++ program which calls a factorial function to calculate N!. N! is the product of all whole numbers from 1 to N.

  Write a program to perform rounding on a floating point

Write a program to perform rounding on a floating point number input by the user, based on the fractional part of the number.

  Display an error message on the terminal

Write a script check1 that prompts for user input of a vector X and displays an error message on the terminal unless every element is nonzero.

  Describing the principle for the law firm company network

Create a cyber-security policy describing the principle, the objective, and policy statement for the law firm's company network.

  What is the overall error for the validation set

What is the overall error for the validation set? What is the percent improvement relative to the naive rule (using the validation set)?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd