Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need an UML diagram package hw2; import java.util.ArrayList; import java.util.Scanner; public class BabyRanking { /** Main method */ public static void main(String[] args) {

I need an UML diagram

package hw2; import java.util.ArrayList; import java.util.Scanner;

public class BabyRanking {

/** Main method */ public static void main(String[] args) { Scanner input = new Scanner(System.in);

// Prompt the user to enter the year, gender and name System.out.print("Enter the year: "); String year = input.nextLine();

System.out.print("Enter the gender: "); String gender = input.nextLine();

System.out.print("Enter the name: "); String name = input.nextLine();

// Create an ArrayList ArrayList list = new ArrayList<>();

// Read text from url try { java.net.URL url = new java.net.URL( "http://www.cs.armstrong.edu/liang/data/babynamesranking" + year + ".txt"); // Create input file from url input = new Scanner(url.openStream()); while (input.hasNext()) { for (int i = 0; i < 5; i++) { list.add(i, input.next()); }

// Display ranking for the name for the year if (list.get(gender(gender)).equals(name)) { System.out.println( name + " is ranked #" + list.get(0) + " in year " + year); System.exit(0); } list.clear(); } } catch (java.net.MalformedURLException ex) { System.out.println("Invalid URL"); } catch (java.io.IOException ex) { System.out.println("I/O Errors: no such file"); }

System.out.println("The name " + name + " is not ranked in year " + year); }

/** Returns the index for the corresponding gender */ public static int gender(String gender) { if (gender.equals("M")) return 1; else return 3; } }

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

Step: 3

blur-text-image

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

Discuss the techniques of job analysis.

Answered: 1 week ago

Question

How do we do subnetting in IPv6?Explain with a suitable example.

Answered: 1 week ago

Question

Explain the guideline for job description.

Answered: 1 week ago

Question

What is job description ? State the uses of job description.

Answered: 1 week ago

Question

What are the objectives of job evaluation ?

Answered: 1 week ago