Agriculture planning plays a dominant role in the economic growth and food security of agriculture-based countries such as Sri Lanka. Even though agriculture plays a vital role, there are still several major complications to be addressed. Some of the major complications are lack of knowledge about yield and price resulting in the farmers selecting crops based on experience. Machine learning has a great potential to solve these complications. To this end, this paper proposes a novel system comprises of a mobile application, SMS (Short Message Service), and API (Application Programming Interface) with yield prediction, price prediction, and crop optimization. Several machine learning algorithms were used for yield and price predictions while a generic algorithm was used to optimize crops. The yield was predicted considering the environmental factors while the price was predicted considering supply and demand, import and export, and seasonal effect. To select the best suitable crops to cultivate, the output of yield and price prediction have been used. Yield prediction has been implemented using elastic net, ridge, and multilinear regression. R2 of yield prediction is varied from 0.74 to 0.89 while RMSE value is between 15.69 and 35.05. Price prediction has been implemented using the algorithms of Gradient Boosting Tree, Random Forest, Facebook Prophet, and R2 is varied from 0.72 to 0.92 while RMSE value is between 26.81 and 140.72. Crop optimization has been implemented using the genetic algorithm.