Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package asdfs;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.io.PrintStream;
- import java.util.Scanner;
- import java.util.StringTokenizer;
- public class Sums
- {
- Scanner scan;
- PrintStream out;
- StringTokenizer st;
- String temp = "";
- public Sums() throws Exception
- {
- scan = new Scanner( new File( "sums.in" ) );
- out = new PrintStream(new File("sums.out"));
- }
- public void run() throws Exception
- {
- while (scan.hasNext())
- {
- int sum = 0; //reset the sum
- String s = scan.nextLine();
- int c = 0;
- while (c < s.length())
- {
- temp = "";
- while (s.charAt( c )!= ',')
- {
- temp += s.charAt( c );
- c++;
- }
- sum += Integer.parseInt( temp );
- }
- out.println(sum);
- }
- }
- public static void main( String[] args ) throws Exception
- {
- Sums s = new Sums();
- s.run();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement