Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args)
- {
- int s=0, min=0, max=0;
- try {
- Scanner scanner=new Scanner(new File("src/diverse/in.txt"));
- while(scanner.hasNextLine())
- {
- int x = scanner.nextInt();
- s=s+x;
- }
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- System.out.println("Suma: " + s);
- System.out.println("Media: " + (float)s/6);
- }
- }
- public static void main(String[] args) {
- try (// TODO Auto-generated method stub
- Scanner scanner = new Scanner(System.in)) {
- System.out.println("Tastati lungimea: ");
- int x = scanner.nextInt();
- System.out.println("Tastati latimea: ");
- int y = scanner.nextInt();
- System.out.println("Perimetrul este: " + 2*(x+y));
- System.out.println("Aria este: " + x*y);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement