Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program called Histogram.java that displays a list of distinct characters in an input file and the occurrence of each character. Your program

Write a Java program called Histogram.java that displays a list of distinct characters in an input file and the occurrence of each character. Your program should read an input file name from a user. After that, your program should read characters in the file and display a list of distinct characters and their occurrences. Finally, your program should draw a vertical bar for the occurrences.

In the assignment, you can assume that the number of characters in the input file is less than 200. You can also assume that each line has only one character and theres no extra blank space after each character. Furthermore, you can assume that all characters are capitals and from A to K.

A sample run of your program MUST be like below:

For the assignment, your program has to display the result exactly as the sample run. For instance, when you display a list of character occurrences, your program should display the characters with more than zero occurrence in the ascending order. The height of the vertical bar should be the same as the maximum value of Occurrence. And also, the characters in the vertical bar should come in the order of occurrences. In other words, since the characters from D to K have occurrence 0, it comes first. After that, characters A and C come next because their occurrences are 1. Finally, B is displayed because its occurrence is 3.

image text in transcribed

Write a Java program called Histogram.java that displays a list of distinct characters in an input tile and the occurrence of each eharacte. Your iogram should 1ead an input file name from a use. After that, your program should read characters in the file and display a list of distinct characters and their occurTeces. Finally, your program should draw a veril bafo the occuences For the assignment, your program has.to display the result exactly as the sample run. For instance, when you display a list of character occurrences, your program should display the characters with more than zero occurrence in the ascending order. The height of the vertical bar should be the same as the maxium value of"Occurrence" And aksa the characters in th vertical bar should cone i te order of occurrences. In other words, since the characters from 'D' to 'K have occurrence 0, it comes first. After that, characters . A' and .C' come next because ther occurrences are Finally, 'Bs displayed because ts occurrence is 3. In the assignment, you can assume that the number of characters in the input file is less than 200. Yau can also assume that each line has only one character and there's no extra blank Furthermore, you can assume that all characters are capitals and from 'A' to 'K space after each character This is another sample run of your progranm: Input filenamei Ctmpt2.txt A sample run of your program MUST be like below: Input tilename: C:\\tnp\tl.txt Char Occurrence vertical Bar 12 I 12 For the sample un, tl.txt has the following context: For the sample t2. txt has the following context

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

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago