From 38b8d754d8494770613b7233af6f580e37fe463d Mon Sep 17 00:00:00 2001 From: Lala Date: Fri, 20 Feb 2026 18:49:54 +0400 Subject: [PATCH] Here is the results of lab 1 tasks. --- lab1/pom.xml | 17 ++++++ lab1/src/main/java/com/ironhack/Main.java | 63 +++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 lab1/pom.xml create mode 100644 lab1/src/main/java/com/ironhack/Main.java diff --git a/lab1/pom.xml b/lab1/pom.xml new file mode 100644 index 0000000..b6e0d60 --- /dev/null +++ b/lab1/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + com.ironhack + lab1 + 1.0-SNAPSHOT + + + 17 + 17 + UTF-8 + + + \ No newline at end of file diff --git a/lab1/src/main/java/com/ironhack/Main.java b/lab1/src/main/java/com/ironhack/Main.java new file mode 100644 index 0000000..5777bc7 --- /dev/null +++ b/lab1/src/main/java/com/ironhack/Main.java @@ -0,0 +1,63 @@ +package com.ironhack; + +//TIP To Run code, press or +// click the icon in the gutter. +public class Main { + public static void main(String[] args) { + int nums = 0; + int result = nums; + int[] myArray = {2,3,7,9}; + int min = myArray[0]; + int max = myArray[0]; + int i; + + for (i = 0; i < myArray.length;i++) { + if (myArray[i] < min) { + min = myArray[i]; + } + if (myArray[i] > max) { + max = myArray[i]; + } + } + System.out.println("minimumu " + min); + System.out.println("maximumu " + max); + int difference = max - min; + System.out.println("Differenceleri " + difference); + + /*TASK 2 +Write a Java method that finds the smallest and second smallest elements of a +given array and prints them to the console. +*/ + int [] array2 = {2,3,7,1,9}; + + int smallest = array2[0]; + for (int k=0; k