Nathan Coulas

CCC '15 J2 - Happy or Sad

ccc15j2 JAVA8 06 Nov, 2019 2.811s 3 points

Source Code

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
                      Scanner in = new Scanner(System.in);
        String input = in.nextLine();
        //String[] array = input.split(" ");
        int count = 0;
        boolean has = false;
        
        for(int i = 0; i < input.length(); i++){
            if(input.charAt(i) == ':' && input.charAt(i + 1) == '-' ){
                if(input.charAt(i + 2) == ')'){
                  count++;  
                  has = true;
                }else if(input.charAt(i + 2) == '('){
                count--;
                has = true;
                }
        }
        
        }
        
        if(count > 0){
            System.out.println("happy");
        }else if(count < 0){
            System.out.println("sad");
        }else if(count == 0 && has){
            System.out.println("unsure");   
        }else{
            System.out.println("none");
        }
  
       

    }
}