Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The user should be able to look up a specific name and see a bar graph (produced

ID: 3734960 • Letter: T

Question

The user should be able to look up a specific name and see a bar graph (produced via text characters) of that name’s popularity from 1900-2000. The height of each bar should be scaled according to the name’s rank during each census, with lower rank resulting in a higher bar. (However,rank 0 should result in a bar height of 0.) Each bar should also indicate the name’s numerical rank during that census.If the name entered by the user does not exist in the data, show an appropriate error message.The next page containstwoexamples of what this bar graph might look like. Your formatting does notneed to match this exactly, as long as the same information is conveyed.

The user should be able to change the height of the bar graph above. The example graphs above are scaled to a maximum height of 15 lines of text, but the user should be able tospecifyany height from 10-30 lines. Include error checkingto catch invalid input.
•The user should be able to request a list of the top n names from any of the census years in the data (1900, 1910, 1920, ... , 2000). The program should show a list of the names with rank n from that census, sorted by ascending rank. Note that since both male and female names are included in the file, there may be more than one name per rank!Your program should list all names of the same rank.Include error checking to ensure that the census year is valid and that n is between 1-1000.

Code Organization

Your program should use methods to break the code down into manageable chunks. At minimum, include the following methods (although you are welcome to add more if you want):•A method that handles reading the data file.•A method that prints a bar graph showing the historical popularity of a specific name from 1900-2010. This method should include parameters for name and height of the graph.•A method that shows the top n names from a particular census year. This method should include parameters for year and n. Notes on File Reading There are many ways to read a file in Java. One of the easiest is to use the Scanner class that you’re already familiar with. Instead of having the Scanner object read from System.in, you simply tell it to read from a file. To read the data file for this project, start by placing the data file in your Eclipse project folder. It should go into the root of the folder, outside the bin and src subfolders. Once the file is there, here’s some code that will get you started with reading it from your program:Scanner s = null;try {s = new Scanner(new FileReader("ProjectData.txt"));} catch (FileNotFoundException e) {System.exit(1);// Exit program if file not found}while (s.hasNext()) {// Keep reading until nothing left to readString name = s.next();// Read the first word (the name)int rank1 = s.nextInt();// Read the next integer (rank in 1900)int rank2 = s.nextInt();// Read the second integer (rank in 1910)// etc.}You will also need to add import java.io.*;to your import statements at the top of the source code file.

The Assignment Write a program that reads the provided SSA data file and supports the following features: The user should be able to look up a specific name and see a bar graph (produced via text characters) of that name's popularity from 1900-2000. The height of each bar should be scaled according to the name's rank during each census, with lower rank resulting in a higher bar. (However, rank 0 should result in a bar height of 0.) Each bar should also indicate the name's numerical rank during that census. * If the name entered by the user does not exist in the data, show an appropriate error message The next page contains two examples of what this bar graph might look like. Your formatting does not need to match this exactly, as long as the same information is conveyed. Historical popularity of Erica: (Ranks shown above each bar, e indicates not popular enough to be ranked)

Explanation / Answer

package project.pkg2; import java.util.*; public class Project2 { // Scanner for the console inputs static Scanner console = new Scanner (System.in); public static void main(String[] args) { String name, formatNet; double hours, pay, netPay; // Prints the welcome message from the method. welcomeMessage(); // Every initialized variable receives the return statements from their respected methods. name = getName(); while (!(name.equals("-1"))) { pay = getPay (); hours = getHours (); netPay = calcNet(pay,hours); // Formats the net pay to be 2 decimals. formatNet = String.format("%.2f", netPay); System.out.println(name + "'s net pay is $" + formatNet + " ");} // Method for the welcome message, a void because it returns no values. } static void welcomeMessage () { System.out.println("Welcome to the CIS 220 Payroll Calculator! "); } // Method that prompts the user to enter their name, scans it, then returns it. static String getName () { String name; System.out.println("Please enter the employee's name(Enter a -1 when finished): "); name = console.nextLine(); return name; } //Method that prompts the user to enter their pay rate, scans it, then returns it. static double getPay() { double payRate; System.out.println("Please enter the employee's pay rate: "); payRate = console.nextDouble(); console.nextLine(); return payRate; } //Method that prompts the user to enter their hours worked, scans it, then returns it. static double getHours () { double hours; System.out.println("Please enter the employee's hours worked:"); hours = console.nextDouble(); console.nextLine(); return hours; } //Method that uses the pay rate, hours worked that the user has entered. //determines if the user qualifies for overtime pay or not, then calculates the overall pay //followed by tax reduction, then returns the netpay value. static double calcNet (double pay, double hours) { double net, grossPay; String formatNet; if(hours > 40) { grossPay = (pay * hours) * 1.5; } else { grossPay = pay * hours; } net = grossPay - (grossPay * .15); return net; } }