Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

Here is what a properly completed Test sheet should look like:

 

Statement Problem:

Develop a algorithm which takes an input sequence of characters from the alphabhet  (a,b,c) and compresses it by replacing the each subsequence of a paticular character by a single occurence of the character, and the lenght of the sub string.

e.g

input: AAAAA

Output a3b2c3d1

 

The program should use instansiable classes and should be broken down into a number of methods.

 

Analysis of the problem:

 

Input:

Input, a string, a sequence of characters from the user

 

Output:

A welcome message, a string

The compressed  string which comprises letter, a char and count, an integer.

 

Methods:

start(): responsibile for calling all methods of the program

getinput(): gets the input, string, from the user

displaystring(): displays a welcome message and the string which the user has entered

Compress(): preformd the compression algorithm and displays the output.

 

Algorithm:

 

1) Get the input, a string from user

2) Display a welcome message and the input string

3) Preform the compression algorithm

 

a. get th lenght of the input string

b. loop to end of string

Get the current character of the string

Increment the loop counter

Compare the current copunter to letter

while they are the same

    1. increment the count, i.e. the number of co-occurences of that letter

    2. increment the loop counter

 

Display the letter and the count

Reinitalise count to 1 because we will now beginning counting the co-occurence of a new letter

Go back to step b until the loop index = the lenght of the input of the input string

 

Testing:

keep dreaming.

Back