Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void part4() {
- //TextIO txtIO = new TextIO(); //inicializace objektu
- TextIO txtIO = new TextIO("input.txt");
- int count = 0;
- double sum = 0.0;
- boolean end = false;
- while (!end) {
- String line = txtIO.in.nextLine();
- if (line.length() > 0 && txtIO.isDouble(line)) {
- sum += Double.parseDouble(line);
- count++;
- } else {
- System.err.println("End of input detected!");
- end = true;
- }
- }
- while (!end) {
- }
- System.out.println("Sum of the " + count + " input numbers is " + sum);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement