Computer Science Canada help me expain this assignment on strings |
Author: | asianrandy [ Mon Nov 24, 2008 1:43 pm ] |
Post subject: | help me expain this assignment on strings |
Strings 1.k in class i have to creating a program which offers the user an opportunity to analyze statisical information about a sentence of their choice. don't get it. help me explain it 2.your program will start by asking the user to input a sentence which will be stored in a variable. it can be of any size. then your program should offers a menu with the following choices. i don't get it explain it for me.in the bold, does it mean the size of the font. a) total letters in the entire sentence (punctution is included) b) longest word (and its numbers of letters) c)total words in the sentence d) total amount of each letter (ex. 5 a's, 3 b's, etc). |
Author: | Unforgiven [ Mon Nov 24, 2008 1:49 pm ] |
Post subject: | RE:help me expain this assignment on strings |
I'm reasonably sure that the assignment doesn't care about font. The obvious solution is to just ask your instructor, that's what they're there for. Failing that, though, I'd assume they mean that the length of the string can be of any size. |
Author: | Insectoid [ Mon Nov 24, 2008 2:26 pm ] |
Post subject: | RE:help me expain this assignment on strings |
You could use getch() to add characters to a flexible array of string, and move to the next index when a space is entered. This would be a little buggy, but would be able to easily give you the number of words (using upper() ), the longest word (for loop counting length of each word), total letters (for loop adding length of words to running total) and number of each letter (running total of each word, used in a for loop). |
Author: | andrew. [ Mon Nov 24, 2008 4:06 pm ] | ||
Post subject: | RE:help me expain this assignment on strings | ||
But you can't backspace or change a word you previously entered using insectoid's method. I think the best way to do it is like this:
The main thing to note in the above code is that after get I have : *, which means don't ignore the spaces and copy the whole sentence into one variable. |
Author: | Insectoid [ Mon Nov 24, 2008 4:10 pm ] |
Post subject: | RE:help me expain this assignment on strings |
Andrew- It was complicated, but if you look at my blackjack program (somewhere in Turing Submissions), you can see that I did indeed implement the backspace key into it. It took only a few lines of code and a for loop (because Turing doesn't know how to draw) to use backspace with getch. |
Author: | andrew. [ Mon Nov 24, 2008 4:34 pm ] |
Post subject: | RE:help me expain this assignment on strings |
Well, maybe that method would work but I find my method easier. Anyways, I finished making the program using my method and I think it's easier for a beginner to understand although I do see how your program works. I just think it's hard for a beginner. |
Author: | Insectoid [ Mon Nov 24, 2008 4:37 pm ] |
Post subject: | RE:help me expain this assignment on strings |
True. But it would be FAR easier to do the actual task once you have the whole 'getch()' bit done. I like doing it the complicated but awesomer way. (yippee! incorrect grammar!) |
Author: | asianrandy [ Tue Nov 25, 2008 1:41 pm ] | ||
Post subject: | Re: help me expain this assignment on strings | ||
so far i got this. but i need help fixing this and I'm trying to figure out the total amount of each letter( ex. 5 a's, 3 b's, etc).
|
Author: | andrew. [ Tue Nov 25, 2008 8:16 pm ] |
Post subject: | RE:help me expain this assignment on strings |
First of all, you have end loop before end for. They should be switched. Second, your for loop would take waaayyyyy too long to exit. Add an exit condition (exit when....) or make the loop smaller. Third, for counting each letter, you may want to look into arrays because that's the only way I can think of doing it. |
Author: | asianrandy [ Wed Nov 26, 2008 1:52 pm ] |
Post subject: | RE:help me expain this assignment on strings |
man i can't find it. ahhhh. my head hurts. |
Author: | jbking [ Wed Nov 26, 2008 3:55 pm ] |
Post subject: | RE:help me expain this assignment on strings |
There is a brute force way to do this with a little over a couple dozen individual counters but an array makes for a nicer solution if you find the trick. |
Author: | asianrandy [ Thu Nov 27, 2008 1:32 pm ] |
Post subject: | RE:help me expain this assignment on strings |
i can't find any array, to find the total amount of each letter? |
Author: | jbking [ Thu Nov 27, 2008 2:07 pm ] |
Post subject: | RE:help me expain this assignment on strings |
You don't find an array, you make the array. The array holds 26 numbers which are the number of occurances of a,b,c,...,x,y,z is where we are trying to steer you. |
Author: | asianrandy [ Sat Nov 29, 2008 12:57 pm ] | ||
Post subject: | RE:help me expain this assignment on strings | ||
i need help organzation this and problem need to be fix.
|
Author: | Tyr_God_Of_War [ Mon Dec 01, 2008 2:21 pm ] |
Post subject: | RE:help me expain this assignment on strings |
You have 'get pattern' and 'get sentence' reversed. You are missing a bracket. What are you trying to do with "word := word (pos + size .. *) " ? You don't have an enough 'end for's. I can't understand how you are trying to do what you want to do. |
Author: | asianrandy [ Mon Dec 01, 2008 9:02 pm ] | ||
Post subject: | RE:help me expain this assignment on strings | ||
i need help to find the words in the sentence and total amount of each letter. well the other one i posted didn't work.
|