Question
Histogram.java Description Write a Java program called Histogram.java that displays a count of distinct characters from an input file and the occurrences of each character.
Histogram.java
Description
Write a Java program called Histogram.java that displays a count of distinct characters from an input file and the occurrences of each character. Your program will read an input filename from a user. The program will then read characters from the file and display a list of distinct characters and their occurrences. Finally, the program will draw a vertical bar made up of the letters for the occurrences.
The end result should be exactly like the sample runs. For instance, when displaying a list of character occurrences, your program should display the characters with more than zero occurrence in descending order. The height of the vertical bar should be the same as the maximum value of Occurrence.
Assumptions
Assume that the number of characters in the input file is less than or equal to 200. You may also assume that each line has only one character and theres no extra blank space after each character. Furthermore, you can assume that the only characters will be capitals from A to K.
Description 1
Assumptions 1
Requirements 2
Include an abstract at the beginning of your file with the following information 2
Sample run 1 3
Sample run 2 4
Required methods
This program requires the following methods
-
public static void main(String[] args)
-
This will be the driver for our program. It will call the following methods.
-
-
public static String getFileName()
-
This method will read the filename from the user
-
-
public static void read(char[] letter, int[] letterCount, String filename)
-
This method will read the letters from the filename provided in the previous method
-
-
public static void sort(char[] letter, int[] letterCount)
-
This method will sort the letters
-
-
public static void display(char[] letter, int[] count)
-
This method will display the histogram
-
Requirements
Include an abstract at the beginning of your file with the following information
-
Title: File Name
-
Abstract: Overall purpose (or functionality) of the program.
-
Author: Your name
-
Date: The date you wrote the program
Your program will be graded based on
-
Filename MUST be Histogram.java
-
Compilation without error.
-
Correct output result.
-
Low MOSS score compared to other students
-
I check against all submissions as well as submissions from previous semesters.
-
Please reference the CSUMB academic integrity policies.
-
-
Good programming structure
-
Correct methods and method names.
-
Comments. (Title, Abstract, Author, and Date are mandatory.)
-
Meaningful and related variable names.
Sample run 1
For the sample run1 , tq2.txt contains:
B
A
C
B
B
C
Sample run 2
For sample run 2, tq3.txt has the following context:
H
A
D
B
B
K
H
D
H
H
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started