Advertisement
hasky67

Untitled

Oct 31st, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. public void part4() {
  2. //TextIO txtIO = new TextIO(); //inicializace objektu
  3. TextIO txtIO = new TextIO("input.txt");
  4.  
  5. int count = 0;
  6. double sum = 0.0;
  7. boolean end = false;
  8. while (!end) {
  9. String line = txtIO.in.nextLine();
  10. if (line.length() > 0 && txtIO.isDouble(line)) {
  11. sum += Double.parseDouble(line);
  12. count++;
  13. } else {
  14. System.err.println("End of input detected!");
  15. end = true;
  16. }
  17. }
  18. while (!end) {
  19.  
  20. }
  21. System.out.println("Sum of the " + count + " input numbers is " + sum);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement