Question: Write java codes to list the top 20 boy's names and the top 20 girls's names in 2 seperate files. 1 James 4,873,553 Mary 3,645,781

Write java codes to list the top 20 boy's names and the top 20 girls's names in 2 seperate files. 1 James 4,873,553 Mary 3,645,781 2 John 4,758,222 Patricia 1,566,802 3 Robert 4,671,697 Elizabeth 1,460,672 4 Michael 4,260,846 Jennifer 1,459,443 5 William 3,756,007 Linda 1,447,002 6 David 3,523,378 Barbara 1,421,004 7 Richard 2,516,204 Susan 1,108,052 8 Joseph 2,431,138 Margaret 1,088,523 9 Charles 2,208,407 Jessica 1,036,278 10 Thomas 2,190,077 Dorothy 1,024,035 11 Christopher 1,971,066 Sarah 994,541 12 Daniel 1,821,260 Karen 982,123 13 Matthew 1,522,521 Nancy 981,504 14 Donald 1,395,331 Betty 980,934 15 Anthony 1,365,244 Lisa 963,095 16 Paul 1,342,620 Sandra 871,582 17 Mark 1,335,840 Helen 857,164 18 George 1,290,419 Donna 827,921 19 Steven 1,266,350 Ashley 827,154 20 Kenneth 1,251,552 Kimberly 822,084 21 Andrew 1,210,899 Carol 813,273 22 Edward 1,190,576 Michelle 800,803 23 Brian 1,152,674 Amanda 768,637 24 Joshua 1,150,774 Emily 764,804 25 Kevin 1,141,218 Melissa 745,052 26 Ronald 1,072,612 Laura 738,694 27 Timothy 1,052,116 Deborah 737,873 28 Jason 1,002,840 Stephanie 730,949 29 Jeffrey 967,336 Rebecca 726,005 30 Gary 897,035 Sharon 719,879 31 Ryan 881,205 Cynthia 703,517 32 Nicholas 859,739 Ruth 702,297 33 Eric 858,523 Kathleen 701,176 34 Stephen 841,964 Anna 692,476 35 Jacob 830,530 Shirley 680,656 36 Larry 801,104 Amy 671,450 37 Frank 800,588 Angela 652,592 38 Jonathan 795,190 Virginia 611,162 39 Scott 766,308 Brenda 604,886 40 Justin 753,163 Pamela 593,182 41 Raymond 734,403 Catherine 593,060 42 Brandon 728,678 Katherine 583,339 43 Gregory 701,159 Nicole 574,004 44 Samuel 665,311 Christine 572,546 45 Patrick 652,187 Janet 550,890 46 Benjamin 648,754 Debra 550,055 47 Jack 619,585 Carolyn 547,502 48 Dennis 610,710 Samantha 543,139 49 Jerry 604,196 Rachel 541,755 50 Alexander 582,186 Heather 523,040 51 Tyler 557,953 Maria 518,036 52 Douglas 552,435 Diane 517,192 53 Henry 550,208 Frances 514,461 54 Peter 549,164 Joyce 503,879 55 Walter 545,888 Julie 503,006 56 Aaron 535,407 Martha 481,495 57 Jose 529,880 Joan 477,390 58 Adam 519,942 Evelyn 476,724 59 Harold 516,822 Kelly 467,580 60 Zachary 507,330 Christina 467,139 61 Nathan 494,627 Emma 465,196 62 Carl 471,146 Lauren 452,961 63 Kyle 466,208 Alice 450,513 64 Arthur 463,986 Judith 449,450 65 Gerald 440,934 Marie 445,565 66 Lawrence 434,635 Doris 444,371 67 Roger 434,079 Ann 443,799 68 Albert 431,302 Jean 443,367 69 Keith 430,339 Victoria 439,620 70 Jeremy 422,557 Cheryl 438,855 71 Terry 419,945 Megan 431,928 72 Joe 417,873 Kathryn 424,467 73 Sean 407,064 Andrea 417,737 74 Willie 404,641 Jacqueline 414,116 75 Jesse 386,355 Gloria 407,452 76 Ralph 384,463 Teresa 406,093 77 Billy 380,310 Janice 403,866 78 Austin 376,166 Sara 401,184 79 Bruce 375,947 Rose 398,300 80 Christian 372,606 Julia 392,296 81 Roy 369,332 Hannah 386,264 82 Bryan 366,762 Theresa 385,471 83 Eugene 359,306 Judy 380,750 84 Louis 354,723 Mildred 376,563 85 Harry 348,060 Grace 375,877 86 Wayne 347,297 Beverly 375,705 87 Ethan 339,542 Denise 370,422 88 Jordan 337,961 Marilyn 366,422 89 Russell 337,854 Amber 364,623 90 Alan 333,250 Danielle 360,760 91 Philip 326,130 Brittany 355,030 92 Randy 324,725 Diana 350,713 93 Juan 324,576 Jane 350,665 94 Howard 319,484 Lori 340,153 95 Vincent 313,243 Olivia 334,115 96 Bobby 311,414 Tiffany 332,906 97 Dylan 311,182 Kathy 332,831 98 Johnny 303,915 Tammy 331,441 99 Phillip 299,758 Crystal 326,134 100 Craig 297,201 Madison 325,505 

public static void main(String[] args) throws Exception {

File file1 = new File ("names.txt");

File file2 = new File ("namesBoy.txt");

File file3 = new File ("namesGirl.txt");

Scanner input = new Scanner (file1);

PrintWriter output1 = new PrintWriter( file2 );

// output2 here

// Apply a loop

{

input.next();

input.next(); // then write into file2

input.next();

input.next(); // write into ...

input.next();

} // again, do NOT forget your loop

file1.close(); file2.close(); file3.close();

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!