diff --git a/LAB JAVA LOOPS AND VERSION CONTROL/.vscode/settings.json b/LAB JAVA LOOPS AND VERSION CONTROL/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/LAB JAVA LOOPS AND VERSION CONTROL/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/LAB JAVA LOOPS AND VERSION CONTROL/README.md b/LAB JAVA LOOPS AND VERSION CONTROL/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/LAB JAVA LOOPS AND VERSION CONTROL/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/LAB JAVA LOOPS AND VERSION CONTROL/src/Main.java b/LAB JAVA LOOPS AND VERSION CONTROL/src/Main.java new file mode 100644 index 0000000..5615912 --- /dev/null +++ b/LAB JAVA LOOPS AND VERSION CONTROL/src/Main.java @@ -0,0 +1,33 @@ +package src.java; +import java.lang.reflect.Array; +import java.util.Arrays; + +class Main{ + public static void main(String[] args){ + System.out.println("Hello World"); + } + + +//task 1 +public static int difference(int[] arr){ + Arrays.sort(arr); + return arr[arr.length-1] - arr[0]; +} + + +//task 2 +public static void smallest(int[] arr){ + Arrays.sort(arr); + + System.out.println(arr[0]); + System.out.println(arr[1]); +} + +//task3 + +public static int expression(int x, int y){ + return (int) (x*x + Math.pow((4*y/5)-x, 2)); + +} + +} \ No newline at end of file