Love and Hate Swap


Submit solution

Points: 100
Time limit: 20.0s
Memory limit: 256M

Problem type
Allowed languages
Java 19

請撰寫一個程式,讀取使用者輸入的一行英文文字(內容包含喜歡什麼、討厭什麼,各一個,順序不定),依序完成下列處理,並輸出修改後的結果:

  • 將單字 hate 替換為 love、love 替換為 hate;
  • 替換後,輸出的 hate 要全大寫(HATE),love 要加上雙引號("love")。

Input Specification

一行英文文字,單字之間以一個空格隔開,不含標點符號。

Output Specification

輸出修改後的文字。

Constraints

  • 輸入中 love 與 hate 恰好各出現一次,且都是小寫的獨立單字。
  • 其他單字不會包含 love 或 hate 作為子字串。
  • 一行長度不超過 200 個字元。

Sample Input 1

I hate rain and love snow

Sample Output 1

I "love" rain and HATE snow

Sample Input 2

I love dog and hate cat

Sample Output 2

I HATE dog and "love" cat

Note: 雙引號請使用英文半形 ",不是全形或彎引號。


Comments

There are no comments at the moment.