|
L1
Oct 26, 2001 20:12:18 GMT -5
Post by Sylph on Oct 26, 2001 20:12:18 GMT -5
anybody know how to approach this? i made one that works ;D, but then i realized the user might also input a line w/ spaces, not just a word. my program makes use of a character that wasn't supposed to be inputted by the user (space), but now that won't work. is there some weird character that the user cannot input?
|
|
|
L1
Oct 26, 2001 21:27:30 GMT -5
Post by Majin_Blues on Oct 26, 2001 21:27:30 GMT -5
i tried running that and it seems to print for any character other than a letter... darn if statement...
did you use "toUpperCase" in your if statement?
|
|
|
L1
Oct 26, 2001 21:40:43 GMT -5
Post by Majin_Blues on Oct 26, 2001 21:40:43 GMT -5
i think i found a way to account for that space...
just limit the available char values
that is, take a look at the first character's value and make sure it's in the "value range" of all possible letters... not symbols or numbers
it's a tad messy but it works
|
|
|
L1
Oct 27, 2001 7:50:31 GMT -5
Post by Sylph on Oct 27, 2001 7:50:31 GMT -5
i don't really understand why u need to limit the char values. i did use toUpperCase in my if statement, and it works -- this way, i don't have to deal with ASCII values and such. i meant i need a weird character the user can't input. cuz in my program, i stored a long String containing all the first-letter-capitalized lines, seperated by spaces, and that's how i could distinguish b/w them and print them. but i guess i'll use this other structure i originally started w/, but seemed to complicated...
|
|
|
L1
Oct 27, 2001 8:13:45 GMT -5
Post by TheRock on Oct 27, 2001 8:13:45 GMT -5
I want to make sure I understand the question. when I run the program afewjf [Enter]<input> AFfeg [Enter]<input> AFfeg <output> Sfegee [Enter]<input> Sfegee <output> fwfefe [Enter]<input> jjjjief [Enter]<input> Hefe [Enter]<input> Hefe <output> quit [Enter]<input> <quit the program> is the program run like this?
|
|
|
L1
Oct 27, 2001 9:05:41 GMT -5
Post by Sylph on Oct 27, 2001 9:05:41 GMT -5
i thought u had to output the capitalized lines after they pressed quit. this sucks ass.
|
|
|
L1
Oct 27, 2001 9:33:31 GMT -5
Post by Majin_Blues on Oct 27, 2001 9:33:31 GMT -5
i don't really understand why u need to limit the char values. i did use toUpperCase in my if statement, and it works -- this way, i don't have to deal with ASCII values and such. i meant i need a weird character the user can't input. what if the first character you input was a number, or say some symbol? (e.g. 8, +, ') would the program print that when it isn't supposed to?
|
|
|
L1
Oct 27, 2001 9:44:20 GMT -5
Post by Sylph on Oct 27, 2001 9:44:20 GMT -5
uh-oh. i understand now. how do u know what the value range is? i tried to use a for loop to print all the characters and corresponding numbers using Character.forDigit, but i can only get characters 0 to z. i don't even know how to get the capital letters! what's a radix, anyway? i just put in some random #.
|
|
|
L1
Oct 27, 2001 9:52:33 GMT -5
Post by Majin_Blues on Oct 27, 2001 9:52:33 GMT -5
i just experimented... (checked the value for "A" and "Z" and made sure the values of the letters fit between them) - i didn't do this in the actual program though...
i dunno how to use all that other Character-digit stuff...
got a question though: how do you save so many user inputs without using arrays??
|
|
|
L1
Oct 27, 2001 9:56:47 GMT -5
Post by Sylph on Oct 27, 2001 9:56:47 GMT -5
i used a really long String. but that doesn't matter anymore, because i just read this in the newsgroup: it's a hell lot easier now , but i'll have to rewrite my whole program.
|
|
|
L1
Oct 27, 2001 9:59:41 GMT -5
Post by Majin_Blues on Oct 27, 2001 9:59:41 GMT -5
whew!!! that's candy to my eyes!!! why are they telling us to read carefully when they can't even explain it carefully?? btw, that long string idea, that's pretty good! very clever p.s. i mentioned earlier about the symbols and stuff... don't forget to account for the possibility that the user might enter a blank line!!! (found that out by accident!)
|
|
Jaysin
Junior Member
I am that dude from class...
Posts: 18
|
L1
Oct 27, 2001 10:01:46 GMT -5
Post by Jaysin on Oct 27, 2001 10:01:46 GMT -5
That is what i get too... i think that is right.. but ur best bet is to ask ur Instructor... these instructions are a tad unclear... I want to make sure I understand the question. when I run the program afewjf [Enter]<input> AFfeg [Enter]<input> AFfeg <output> Sfegee [Enter]<input> Sfegee <output> fwfefe [Enter]<input> jjjjief [Enter]<input> Hefe [Enter]<input> Hefe <output> quit [Enter]<input> <quit the program> is the program run like this?
|
|
|
L1
Oct 27, 2001 14:21:13 GMT -5
Post by Brutal_Chicken on Oct 27, 2001 14:21:13 GMT -5
It doesn't say that we have to account for different values for the first character; only when the first character is capital then print, repeat till quit. If it's a space then nothing happens so wouldn't one conditional statement suffice?
EX: BR in = new BR(ISR); // bufferedread... etc String s; String quit = "quit"; while (!s.equals(quit)) { s = in.readLn(); if (s.charAt(0) "==" s.toUpperCase.charAt(0)) System.out.println(s); }
Now as for the "==" can we compare characters in that fashion? Is this completely off the mark? Perhaps a "for" loop might work better.
|
|
|
L1
Oct 27, 2001 15:43:08 GMT -5
Post by Majin_Blues on Oct 27, 2001 15:43:08 GMT -5
For Brutal_Chicken: what if the first character you input was a number, or say some symbol? (e.g. 8, +, ') would the program print that when it isn't supposed to? also, you can compare char values using "==" as for the loop, you might be better off using while so you don't have to initialize counters or stuff like that...
|
|
|
L1
Oct 27, 2001 19:54:23 GMT -5
Post by Sky on Oct 27, 2001 19:54:23 GMT -5
In the API booklet under the Class Character there is a boolean method isLetter which returns true if the char is a letter...so do anyone think we should use it to avoid printing out something like weird characters that is not a letter?
and if there is a weird characters should we do nothing ie treat them as in the case of being lowercase?
|
|