/*
* Erica and Bob participate in a friendly Hackathon that allows each one to solve one question a day out of the three offered. There will be one easy, one medium and one hard question, with points awarded based on difficulty. The winner is the one with the highest score at the end of the competition based on the following scale:

Scoring table

Difficulty    point

Easy (E)             1

Medium (M)     3

Hard (H)          5

There are two strings, erica and bob. Each character erica[i] and bob[i] represent the difficulties of the problems ("E","M",H") solved on day[i] by Erica and Bob. The scoring table associates the points for each question difficulty. Calculate the scores for Erica and Bob. Return the name of the winner: "Erica", "Bob" or "Tie" if they have the same
* */
public class Main {
    public static void main(String[] args) {
        int er = 0;
        int b = 0;
        String erica = "EM";
        String bob = "EM";

        String ericaUpper = erica.toUpperCase();
        String bobUpper = bob.toUpperCase();

        for (int i = 0; i < erica.length(); i++){
            char c = ericaUpper.charAt(i);
            if (c=='E'){
                er++;
            }
            if (c=='M'){
                er+=3;
            }
            if (c=='H'){
                er+=5;
            }
        }

        for (int i = 0; i < bob.length(); i++){
            char d = bobUpper.charAt(i);
            if (d=='E'){
                b++;
            }
            if (d=='M'){
                b+=3;
            }
            if (d=='H'){
                b+=5;
            }
        }

        if(er > b) {
            System.out.println("Erica");
        } else if(er < b) {
            System.out.println("Bob");
        } else {
            System.out.println("Tie");
        }
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: