Please enable JavaScript to use CodeHS

Letter Histogram

In this project, students will use string and character functions to create a histogram of the number of letters in a given text. The project reads in a file for students and they will then analyze each letter of the file to create and display a histogram of the letters.

Easy

1 Hour

High School

Project Description

Background

When typewriters first became common in the 1800s, the QWERTY keyboard was designed to help alleviate jams with the keys. The idea was to space out common letter combinations and to alternate the hand that was used to type the letters.  Common keys such as A and E were also placed at easier locations compared to keys such as Q and Z.

Over time, the English language has changed, so is the keyboard still laid out in an optimal pattern for common letters?

Your Task

To find out, you are going to read in a text file in and count the number of occurrences of each letter from a-z (ignoring capitalization). Once you finished that, you are going to print out a histogram of the results. For example:

A: ****
B: *
C: *
D: ******
E: **

To print the histogram, you want to benchmark the highest value letter at 10 stars and calculate the value of each star based on that number.

Project Demo

Explore this program before assigning it!

Project Overview

Here is an outline of the project activities: