Group 1.
View the problem statement here.

Click the image to view enlarged version.
Its a good practice to use functions to do the calculation part and use the main() only for calling relevant functions and I/O.

Just click on the images for clarity.
Request: Please take the quiz or leave your comment to help me make this site more useful. Thanks