COAD02 - Editorial

Problem Code: COAD02

Problem link is here

Problem Name: Simple Sum

Contest Name: CodeAdda Practice Contest – 2 (CPC2016)

Author: Yatharth Oza (Username: yatharth100)

Difficulty: Easy



Here One String is given as a input in each test case. Each String contains some Float numbers join by one character ‘e’. You just need to extract all floats and do sum of all numbers and print output which is correct up to 4 decimal places.


For this problem we can traverse whole input string by putting one by one character in one temporary string and when ‘e’ comes we will stop and then we can convert string to float and add in ‘Sum’ variable which stores current sum of input. At last we can just return the value of ‘Sum’. After each iteration we make temporary string null and Sum value to 0.
If you are doing your code in C then you can make approach like this. But, If you are using JAVA or any object oriented language then it provides directly “split(“e”)” function from which you can make given approach directly.


/*Solution is in JAVA and filename is */
import java.util.*;
import java.lang.*;
class Main
	public static void main (String[] args) throws java.lang.Exception
		float sum=0,temp;
		long t;
		Scanner in=new Scanner(;
		String str =;
		String[] no = str.split("e");
		for(int i=0;i<no.length;i++)
		System.out.printf("%.4f\n", sum);