Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void firstline() {
- Scanner in = new Scanner(System.in);
- out.printf("");
- String Line = in.nextLine();
- Scanner line = new Scanner(Line);
- int somcijfers = 0;
- while(line.hasNext()) {
- somcijfers += line.nextInt();
- }
- out.printf("%d", somcijfers);
- }
- void start() {
- firstline();
- }
- String s = "Piet van Gogh_5 6 7 4 5 6";
- String vals = s.substring(s.lastIndexOf('_') + 1);
- String[] nums = vals.split(" ");
- try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
- String line = br.readLine();
- String[] splitLine = line.split("_");
- String[] numbers = splitLine[1].split(" ");
- Integer sum = Stream.of(numbers).mapToInt(Integer::valueOf).sum();
- System.out.println(sum);
- } catch (IOException e) {
- e.printStackTrace();
- }
Add Comment
Please, Sign In to add comment