Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Map;
- import java.util.Scanner;
- import java.util.TreeMap;
- public class GandalfsStash {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- Map<String,Integer> foods = new TreeMap<>();
- foods.put("cram", 2);
- foods.put("lembas", 3);
- foods.put("apple", 1);
- foods.put("melon", 1);
- foods.put("honeycake", 5);
- foods.put("mushrooms", -10);
- int mood = Integer.parseInt(input.nextLine());
- String[] inputText = input.nextLine().split("[\\W\\s\\_]+");
- for (int i = 0; i < inputText.length; i++){
- if (foods.containsKey(inputText[i].toLowerCase())){
- mood+=foods.get(inputText[i].toLowerCase());
- }
- else {
- mood--;
- }
- }
- System.out.println(mood);
- if (mood < -5){
- System.out.println("Angry");
- }
- else if (mood >= -5 && mood < 0){
- System.out.println("Sad");
- }
- else if (mood >= 0 && mood < 15){
- System.out.println("Happy");
- }
- else {
- System.out.println("Special JavaScript mood");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment