Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

  1. Title: File Name

  2. Abstract: Overall purpose (or functionality) of the program.

  3. Author: Your name

  4. Date: The date you wrote the program

Your program will be graded based on

  1. Filename MUST be Histogram.java

  2. Compilation without error.

  3. Correct output result.

  4. Low MOSS score compared to other students

    1. I check against all submissions as well as submissions from previous semesters.

    2. Please reference the CSUMB academic integrity policies.

  5. Good programming structure

  6. Correct methods and method names.

  7. Comments. (Title, Abstract, Author, and Date are mandatory.)

  8. 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

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

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

What are the differences between transactional and analytic SRM?

Answered: 1 week ago

Question

9. Identify four interaction styles in intercultural marriages.

Answered: 1 week ago