write mainFunction

calls on 3 calculation functions