#include <stdio.h>
#include <stdlib.h>
#include <strings.h>

int main()
{
    int i,trial ;
    int diceRoll;
    int total =0 ;
    int total1 =0 ;
    char firstName[20];
    char secondName[20];
    char fullName[40];
    char sum;


    printf("What is your first name?\n ");
    scanf(" %s",firstName);

    printf("What is your last name?\n ");
    scanf(" %s",secondName);

    strcpy(fullName, firstName);
    strcat(fullName, " ");
    strcat(fullName, secondName);

    printf("Welcome %s to the DICE ROLLING GAME!\n",fullName);

    do{

        total=total1;
        printf("The initial sum of the 3 dice rolls is: %i\n",total);


        printf("Predict if the next sum of 3 dice rolls is going to be:\n");
        printf("   A) Higher \t (H) \n");
        printf("   B) lower \t (L) \n");
        printf("   C) Same \t (S) \n");
        scanf(" %c",&sum);

        total1=0;

        for( i=0; i<3; i++){


            diceRoll = ( rand()%6) + 1;
            printf("The number on the dice on %d roll is %d \n",i ,diceRoll);

            total1+=diceRoll;
            printf("The sum of the three dice rolls is %i\n",total1);
        }

        if ( (total1>total) && (sum=='H'))
              printf("Congratulations! You have won the game!\n");

        else if ( (total1==total) && (sum=='S'))
              printf("Congratulations! You have won the game!\n");

        else if( (total1<total) && (sum=='L'))
              printf("Congratulations! You have won the game!\n");

        else
              printf("Wrong! Try again!\n");



        printf("Enter any number to continue playing or enter '0' to stop playing\n");
        scanf(" %i",&trial);

    }while(trial>=1);

    return 0;
}