CS 1301 Program 2 Fall 2014


Design, Test Cases, Source Code due: Friday, Sept 26th by 11:59PM

Grading Criteria for Program 2 CS 1301 Fall 2014

Syntax checking- if it does not run without errors or warnings, it will not be graded
Program
Correctness
60

Gets data from user

Counters are initialized properly and are of the correct type

Calculations are done correctly

If or switch statements used correctly

Displays results correctly, both values, text and formatting (line breaks, etc.)
Testing 15

Test cases /15
Program Design 15

Individual design /15

Design and source code are NOT the same thing (10 point penalty!)
Style and
documentation
10

Prolog Comment with Name, Section, Email, Date, Purpose

Meaningful Variable Names

Documentation of Code

Source code Indentation/
   formatting/ whitespace
Total 100
Late Penalty

I have the authority to deduct points for other items which do not follow the program specifications, as given in the assignment page, or the documentation or other standards stated on the class web page.

Educational Goals: The educational goals of this program are that the student should use the concepts of

In this assignment, you will write a Java program that counts the number of vowels, consonants and words in a string. The program should take as input a string from the user, which could be one word, one sentence, up to several sentences. Your program then iterates through every character of the string and computes the total number of consonants as follows:

Sample interaction with the program:

Example run 1:
Enter some text: The quick brown fox jumps over the lazy dog
Your input has 11 vowels
Your input has 24 consonants
Your input has 9 words
The ratio vowels/consonants is 0.45833334
The ratio vowels/words is 1.2222222


Example run 2:
Enter some text: aeiou 123454
Your input has 5 vowels
Your input has 0 consonants
Your input has 2 words
The ratio vowels/consonants is Infinity
The ratio vowels/words is 2.5


Example run 3:
Enter some text: Please make sure you ALWAYS read directions carefully.
Your input had 18 vowels
Your input had 28 consonants
Your input had 8 words
The ratio vowels/consonants is 0.64285713
The ratio vowels/words is 2.25

Notes: the counters cannot be fractions. You have to count words/vowels/consonants with whole numbers. If you choose to use the isDigit() method, that method belongs to the Character class, not char.

Test Cases

First, read the assignment carefully. Look for how the program is supposed to behave. You do not know what the code looks like - that is fine. The assignment gives some examples of normal runs. There are other test cases needed. Create a test case table similar to that of program 1. The test cases are due at the same time your design and code are due.

Design


Decide on what steps you will need to perform to solve this problem. Make a numbered list and put it in Java form. Save this Java file as "design2.java".
// step 1: prompt for text
// ... enter your steps here
//  loop: for each character in the string do this:
    // loop body step 1: 
    // loop body step 2: 
    // etc
// compute things
// output things
and individually fill in the missing steps in the design. This is due by Friday, September 26th, 11:59PM same time the code and test cases.

Implement the design

Write a Java program to implement your design. Make a copy of the Java file you have that has the design in it and write your Java code between the commented lines of the design. Make sure you eliminate any syntax and semantics errors. Here is where test cases come in handy! Submit your individual source code with the link here. Choose the menu choices of "Code" and "Program 1". This is due by Friday, September 26th, 11:59PM.

There are several specifications about how your program should be written.

Please read the documentation standard on the class web page. As you can see from looking at the grading criteria, we will be looking to see how you meet these standards. Note particularly that we require a prolog!

Remember that the program must run with NO errors or warnings. If it does not, it will not be graded!