Question
Java Program The voter participation data we will work with is stored in a Word document Presidential Elections.docx or you can find on http://www.sos.wa.gov/elections/voter_participation.aspx. Its
Java Program
The voter participation data we will work with is stored in a Word document Presidential Elections.docx or you can find on http://www.sos.wa.gov/elections/voter_participation.aspx.
Its expected that you hard code the bar data in the main() method, i.e., I expect to see the corresponding values typed into your program and passed to the functions as arguments. Outside of this, you should have no magic numbers; use values from the website instead.
1. Constants Definition
For this program, gather no input from the user. Instead, define constants to hold key data, making it easy to change the values to test your program.
Define at least these constants to hold general histogram settings:
Constant | Description | Sample |
Histogram title | Text that will appear centered (over a 80-character space) before the histogram is displayed. One blank line follows it. | "Presidential Elections" |
Histogram characters | The character to be repeated to create the data bar | T, R, V |
Scale | Use a scale for the chart to create bars in the appropriate size | 1000000 |
2. Output
The output of the program is a character-based histogram showing some bars of data taking from the website. Use at least 5 different years. The header should be in the center of the first line.
Dont hardcode numbers, e.g., for the axis values. In other words, dont have a print statement that prints a string literal 5000 10000 15000 ; write a proper loop instead and use steps and scales. The same goes for tick marks.
You dont need to make the number range flexible; see the top values in the file.
Also, you dont need to guard against bad data. But you should test your program with values that are in the specified ranges that should work.
1. Calculations
There are no special calculations. Do the ones you need to create the desired output.
You may wish to use the String length method; this one is allowed.
Example:
String userName = "Any Name";
int userNameLen = userName.length();
2. Code Implementation
Create a class called Histogram. Follow the provided Course Style Guide.
5.1 Hierarchy
Create the following static functions. Use this exact call hierarchy:
main() should consist of a series of function calls and nothing more
printHeader() should accept one parameter the name of the chart
createBar() will be an overloaded method
the firsts variant should accept four parameters:
- an integer specifying the bar title (the year)
- an integer indicating the bar value
- the character to be repeated to create the data bar
- the scale
the second variant accepts three parameters, the same as the first but excluding the year.
createAxis() should accept one parameter a step
emptyRow() should accept no parameters
None of the functions should return any value
5.2 What You May Use
Constants (at class level), using the recommended casing and word separator
Variables (but not class-level ones)
Assignment and calculations
Definite loops
Console output
5.3 What You May Not Use
Indefinite loops (no while)
Selection control structures (no if) unless youre doing something way above and beyond
Arrays, lists, or other data structures or objects we havent covered
Libraries or methods we havent covered
1. Other Requirements
Your design must use procedural decomposition.
Use class constants where appropriate.
The program must start with main().
Your file must have a program comment at the top. This description, at a minimum, is one to two lines explaining what the program does.
Include your name and date in the file comments.
Each method must include a block comment that describes what the method does a description of parameters (if there are any) what is returned (if anything is returned)
In addition to the block comments, also include algorithm comments, that help to explain your algorithms.
Use good style, such as good variable and method names, class constants, appropriate indentation, etc.
Presidential Elections 2000 I TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT 2004 ITTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT 2008 I TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT 2012 ITTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT 2016 ITTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT 0 1000000 2000000 3000000 4000000 5000000 6000000Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started