1

I was working on my Computer Science assignment and I found several sentences to be little vague to me.

*The Clinton/Trump campaigns want to target advertising to specific regions in the nation. To do this, they want you to analyze the data for particular regions of the nation. To do this, you should first prompt the user to enter the number of states in the region, reprompting if the user enters a non-positive number (you don't need to check that there are fewer than 51 states in the region since this program is intended to work for arbitrary files). Then, prompt for each of the state codes one at a time. The user will not necessarily enter them in sorted order. Finally, print the following message to the screen:{Obama,Romney} won the popular vote by N points in the region. Note that the {} above is standard notation to indicate that you print one of the options.

If at any point an illegal state is entered, you should just print the following error message: XX is not a legal state In that case, you should reprompt for the entire region (but not region size) again. You do not need to check that the entered states are distinct. *

Please read only the bolded sentences and ignore the rests.

My question is, what am I supposed to ask users to enter for the first and the second?

The first bolded text to me, sounds like I'm testing the user to see if they know how many states are there in the United States.

The second bolded text says to 'prompt for each of the state codes one at a time.' It's asking user to input state codes, which sounds like okay, but what about the first bolded text?

I wonder if it's just me can't understand it clearly.
Do they make sense?
If so, what do they mean?

migrated from english.stackexchange.com Oct 7 '16 at 18:26

This question came from our site for linguists, etymologists, and serious English language enthusiasts.

  • 2
    The user gets to decide on what region of the US to examine. Say it's the New England. The user would enter 6 (for the six states in New England). Then the user would enter ME, NH, VT, MA, RI, CT. – rajah9 Oct 6 '16 at 21:19
  • So, I should ask the user to enter the regions such as US Midwest and U.S. South? – Minjae Oct 6 '16 at 22:15
  • @Minjae No. The "region" is custom-defined by the user. They will tell you (a) how many states they want their region to include, and (b) which states they want to include (by entering their codes). – michael.hor257k Oct 6 '16 at 22:31
  • @michael.hor257k So, I should ask users to (A) enter numbers the States, or a State they wish to search, and (B) ask for specific States they wish to search for? For example, if I'm the user and I answer the (A) as 4, then I can enter 4 States to look up the election result for (B)? – Minjae Oct 6 '16 at 22:39
  • @Minjae Yes, that's how the assignment wants it. – michael.hor257k Oct 6 '16 at 22:50
0

The very first sentence is the key. They have subdivided the nation (the United States) into some number of informal or arbitrary regions - 'the Great Plains', 'the Southeast', 'the Mountain West'.

The first prompt is to enter the number of states in the region you want to consider. For example, 6.

The second prompt is to enter the state codes for each state in that region. For example, ME, MA, NH, VT, RI, CT - which are the states in the generally accepted definition of the New England region.

From the context, this seems to be a programming exercise, so the author of the problem is not concerned with what states ought to be, or are customarily, grouped with each other. The author is only concerned that you develop software that validates that what is entered as a state code is actually a valid code.

The third bolded line says that if the user enters a non-valid state code, such as XY, you will ask the user to enter all the state codes over again.

  • Thanks! After I read your post and read the instruction again, it makes sense at all! – Minjae Oct 7 '16 at 3:47
0

They are speaking to the individual States that make up the US of A like California or Maryland. It would have been clearer if they had capitalized the word"State" to indicate a proper name rather than a physical "state" such as "at rest or in motion".

  • I still don't get it, so what should user enter for the first and the second time? – Minjae Oct 6 '16 at 22:18
  • States in a region like the Mid-Wst. and then the "State Codes" IA, IL, IN OH,... – Dave Oct 7 '16 at 0:26
0

The first bolded part means you're looking for a number. For example, 2 if you're analyzing the non-contiguous US (Alaska & Hawaii). Remember, you're looking to analyze a part of the country with this program. This is important in the elections, since you don't want to be campaigning in an area that you're likely to win as it is.

The second part can easily be understood with context, which I found here (emphasis mine):

This file contains the popular vote results from the 2012 election. There is one row per state (including DC), and the file is sorted by state name. Each row has 5 fields in order:
Popular vote for Obama
Popular vote for Romney
Popular vote for all other candidates
Total popular vote in state
The state's abbreviation

The first 4 columns are integers, while the last one is a string (the string happens to be 2 characters, but that shouldn't affect you for this program).

The third statement indicates you're looking for program flow like this:

Input number of states to test for:

2

Input state abbreviation:

AL

Input state abbreviation:

XX

XX is not a legal state
Input state abbreviation:

AL

Input state abbreviation:

HI

{Obama,Romney} won the popular vote by N points in the region.

Essentially, each time you run the program, it should ask for the region size only at the beginning. After it gets a valid number for the region size, it should ask for state abbreviations that number of times, unless it gets an invalid input. When you get invalid input, you go back to iteration 0 and need to start over collecting state abbreviations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy