Vowel Histogram Generator

Verified

Added on  2019/09/16

|3
|489
|326
Project
AI Summary
The assignment involves reading a line of text from the keyboard and generating a histogram of the vowels that occur in the text. The program should be written in Java, using the class name A9. It will prompt the user for a phrase, display the phrase, and then generate a histogram of the vowels in the phrase. The histogram will be displayed both horizontally (as stars) and vertically (in a column format). Additional points can be earned by adding an extra method to print the histogram vertically.

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
The following Java program prompts the user and reads in a line of text, then displays the text. The
class name is A9. You should not change the class name.
/**
* A simple program that prompts the user
* for a line of text.
*/
import java.util.Scanner;
public class A9 {
public static String getPhrase () {
Scanner input = new Scanner(System.in);
System.out.print ("Enter a phrase: ");
String phrase = input.nextLine();
return phrase;
}
public static void reportPhrase (String phrase) {
System.out.println (phrase);
}
public static void printHistogram (String phrase) {
// Your code here
}
public static void main(String args[]) {
String phrase;
phrase = getPhrase ();
reportPhrase (phrase);

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
// Call the method printHistogram here
}
}
This assignment involves reading a line of text from the keyboard, and generating a histogram of the
vowels that occur in the text. You will edit the program supplied above, adding the code to generate
the histogram.
For example, if the user entered
Alphabet soup is my favorite soup in the whole world.
your program would display:
a: * * *
e: * * * *
i: * * *
o: * * * * *
u: * *
Notice that it is case-insensitive.
If the user entered
Tomato TOO.
your program would display:
a: *
e:
i:
o: * * * *
u:
You must write the code to generate the histogram in the printHistogram method (not in the main
method).
Call printHistogram from the main method, passing the text (entered by the user) as an
argument.
You may add more methods if you wish.
Do not use arrays, or any other concepts not yet covered in the course.
You only need to submit your A9.java file.
Start early - there is opportunity for extra points (see below) but it requires more work!! Make
sure your program is perfect before attempting the extra credit.
Extra Credit (+ 5 points):
Add an extra method "printVerticalHistogram" to the class A9, to print the histogram in the following
orientation:
Document Page
Example 1: Alphabet soup is my favorite soup in the whole world.
*
* *
* * * *
* * * * *
* * * * *
a e i o u
Example 2: Tomato TOO.
*
*
*
* *
a e i o u
Call both methods, printHistogram and printVerticalHistogram, from your main, to show both
orientations in the output.
1 out of 3
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]