Canadian Computing Competition: 2015 Stage 1, Junior #2
We often include emoticons in our text messages to indicate how we are feeling. The three consecutive characters :-)
indicate a happy face and the three consecutive characters :-(
indicate a sad face. Write a program to determine the overall mood of a message.
Input Specification
There will be one line of input that contains between and
characters.
Output Specification
The output is determined by the following rules:
- If the input line does not contain any happy or sad emoticons, output
none
. - Otherwise, if the input line contains an equal number of happy and sad emoticons, output
unsure
. - Otherwise, if the input line contains more happy than sad emoticons, output
happy
. - Otherwise, if the input line contains more sad than happy emoticons, output
sad
.
Sample Input 1
How are you :-) doing :-( today :-)?
Output for Sample Input 1
happy
Sample Input 2
:)
Output for Sample Input 2
none
Sample Input 3
This :-(is str :-(:-a(nge te:-)xt.
Output for Sample Input 3
sad
Comments
i suck at java! can anyone help!!
Hint:
This comment is hidden due to too much negative feedback. Show it anyway.
aimalie98 I just tryed your code with and in stead of you "or" in the first if sentence and it is judged AC in all trials! So thank you for showing me how it can be written better that I have done it. JoeP
This comment is hidden due to too much negative feedback. Show it anyway.
Technically, the code is correct, it's the order in which each if statement is written out (although I changed it up just a bit).
the order is:
I posted it in this order and I got all of them correct.
This whole thread really helped me too, because I was lost with doing strings, and not just integers.
I think the right answer is this:
天才,多谢你的启发性思考,祝新年快乐