Advertisement
leonard007

Untitled

Sep 28th, 2022
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. public static void main(String[] args)
  2. {
  3. int s=0, min=0, max=0;
  4. try {
  5. Scanner scanner=new Scanner(new File("src/diverse/in.txt"));
  6.  
  7. while(scanner.hasNextLine())
  8. {
  9. int x = scanner.nextInt();
  10. s=s+x;
  11.  
  12.  
  13. }
  14. } catch (FileNotFoundException e) {
  15. // TODO Auto-generated catch block
  16. e.printStackTrace();
  17. }
  18. System.out.println("Suma: " + s);
  19. System.out.println("Media: " + (float)s/6);
  20.  
  21.  
  22. }
  23. }
  24.  
  25. public static void main(String[] args) {
  26. try (// TODO Auto-generated method stub
  27. Scanner scanner = new Scanner(System.in)) {
  28. System.out.println("Tastati lungimea: ");
  29. int x = scanner.nextInt();
  30. System.out.println("Tastati latimea: ");
  31. int y = scanner.nextInt();
  32. System.out.println("Perimetrul este: " + 2*(x+y));
  33. System.out.println("Aria este: " + x*y);
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement