Question: Java Write a program that allows the user to specify a filename on the command line. If the filename is not specified, the program prompts

Java

Write a program that allows the user to specify a filename on the command line. If the filename is not specified, the program prompts the user for the filename. The program then prints the number of characters, words, and lines in that file. Use a class with a constructor that takes a File object and methods to get the line count, word count, and character count.

Example:

Enter Filename: BabyNames.txt BabyNames.txt 101 500 2999

Inside the file for BabyNames.txt :

1 Michael 65,275 Jessica 46,470

2 Christopher 52,331 Ashley 45,553

3 Matthew 44,794 Brittany 36,534

4 Joshua 43,216 Amanda 34,405

5 Daniel 33,809 Samantha 25,865

6 David 33,739 Sarah 25,810

7 Andrew 33,653 Stephanie 24,859

8 James 32,344 Jennifer 22,219

9 Justin 30,635 Elizabeth 20,742

10 Joseph 30,124 Lauren 20,499

11 Ryan 29,242 Megan 20,256

12 John 29,066 Emily 19,361

13 Robert 28,865 Nicole 17,950

14 Nicholas 27,899 Kayla 17,536

15 Anthony 25,074 Amber 15,862

16 William 24,887 Rachel 15,704

17 Jonathan 24,064 Courtney 15,378

18 Kyle 22,698 Danielle 14,330

19 Brandon 22,155 Heather 14,217

20 Jacob 22,005 Melissa 13,997

21 Tyler 20,631 Rebecca 13,670

22 Zachary 20,424 Michelle 13,418

23 Kevin 20,403 Tiffany 13,157

24 Eric 19,412 Chelsea 12,782

25 Steven 18,753 Christina 11,925

26 Thomas 18,214 Katherine 11,618

27 Brian 16,919 Alyssa 11,262

28 Alexander 16,183 Jasmine 11,033

29 Jordan 16,131 Laura 10,908

30 Timothy 15,685 Hannah 10,274

31 Cody 15,392 Kimberly 10,193

32 Adam 14,708 Kelsey 9,494

33 Benjamin 14,619 Victoria 9,104

34 Aaron 14,550 Sara 8,973

35 Richard 13,574 Mary 8,665

36 Patrick 12,373 Erica 8,604

37 Sean 12,014 Alexandra 8,507

38 Charles 11,991 Amy 8,457

39 Stephen 11,940 Crystal 8,218

40 Jeremy 11,685 Andrea 8,211

41 Jose 11,508 Kelly 8,134

42 Travis 11,454 Kristen 8,073

43 Jeffrey 10,979 Erin 7,987

44 Nathan 10,934 Brittney 7,427

45 Samuel 10,883 Anna 7,290

46 Jason 10,680 Taylor 7,255

47 Mark 10,680 Maria 7,181

48 Jesse 8,980 Allison 7,131

49 Paul 8,579 Cassandra 7,052

50 Dustin 8,455 Caitlin 7,026

51 Gregory 8,377 Lindsey 6,781

52 Kenneth 8,258 Angela 6,664

53 Scott 8,083 Katie 6,513

54 Derek 8,075 Alicia 6,510

55 Austin 7,909 Jamie 6,509

56 Corey 7,690 Vanessa 6,405

57 Bryan 7,436 Kathryn 6,350

58 Ethan 6,988 Morgan 6,047

59 Alex 6,941 Jordan 5,955

60 Christian 6,776 Whitney 5,904

61 Juan 6,737 Brianna 5,678

62 Cameron 6,663 Christine 5,676

63 Jared 6,639 Natalie 5,633

64 Taylor 6,574 Lisa 5,344

65 Bradley 6,431 Kristin 5,300

66 Luis 5,788 Alexis 5,256

67 Cory 5,763 Jacqueline 5,237

68 Edward 5,741 Shannon 5,185

69 Shawn 5,719 Lindsay 5,037

70 Ian 5,460 Brooke 4,988

71 Evan 5,307 Catherine 4,893

72 Marcus 5,296 Olivia 4,623

73 Shane 5,273 April 4,570

74 Peter 5,215 Erika 4,566

75 Carlos 5,207 Katelyn 4,486

76 Trevor 5,140 Monica 4,452

77 Antonio 4,864 Kristina 4,389

78 Vincent 4,798 Kaitlyn 4,313

79 George 4,564 Paige 4,112

80 Keith 4,481 Molly 3,964

81 Phillip 4,453 Jenna 3,957

82 Victor 4,441 Leah 3,924

83 Dylan 4,414 Julia 3,909

84 Brett 4,392 Bianca 3,827

85 Chad 4,349 Tara 3,821

86 Nathaniel 4,342 Melanie 3,812

87 Donald 4,177 Marissa 3,806

88 Caleb 4,153 Cynthia 3,794

89 Casey 4,130 Holly 3,771

90 Jesus 4,127 Abigail 3,718

91 Blake 4,101 Meghan 3,692

92 Raymond 4,061 Kathleen 3,669

93 Mitchell 4,019 Julie 3,655

94 Adrian 3,999 Ariel 3,605

95 Joel 3,998 Alexandria 3,594

96 Erik 3,950 Veronica 3,587

97 Ronald 3,900 Patricia 3,578

98 Devin 3,862 Diana 3,544

99 Garrett 3,756 Gabrielle 3,541

100 Gabriel 3,694 Shelby 3,517

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!