diff --git a/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/Array1.md b/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/Array1.md new file mode 100644 index 0000000..82c4075 --- /dev/null +++ b/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/Array1.md @@ -0,0 +1,23 @@ +# ExercĂ­cios de Arrays + +## Ex1 +```java +final int LENGHT = 100; +int[] a = new int[LENGHT]; +// Code for filling a ommited +for (int = 99; i >= 0; i--) +{ + System.out.print(a[i]); + if (i > 0) { System.out.print(', '); } +} +``` + +## Ex2 +```java +int[] numbers = new int[100]; +for (int k = 0; k < numbers.length; k++) +{ + numbers[k] = k + 1; +} +``` + diff --git a/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/NumberOfDays.class b/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/NumberOfDays.class new file mode 100644 index 0000000..dbb0162 Binary files /dev/null and b/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/NumberOfDays.class differ diff --git a/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/Numbers.class b/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/Numbers.class new file mode 100644 index 0000000..8323d22 Binary files /dev/null and b/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/Numbers.class differ diff --git a/1ano/2semestre/poo/src/tp_codecheck/tp02/Array1.md b/1ano/2semestre/poo/src/tp_codecheck/tp02/Array1.md new file mode 100644 index 0000000..82c4075 --- /dev/null +++ b/1ano/2semestre/poo/src/tp_codecheck/tp02/Array1.md @@ -0,0 +1,23 @@ +# ExercĂ­cios de Arrays + +## Ex1 +```java +final int LENGHT = 100; +int[] a = new int[LENGHT]; +// Code for filling a ommited +for (int = 99; i >= 0; i--) +{ + System.out.print(a[i]); + if (i > 0) { System.out.print(', '); } +} +``` + +## Ex2 +```java +int[] numbers = new int[100]; +for (int k = 0; k < numbers.length; k++) +{ + numbers[k] = k + 1; +} +``` + diff --git a/1ano/2semestre/poo/src/tp_codecheck/tp02/NumberOfDays.java b/1ano/2semestre/poo/src/tp_codecheck/tp02/NumberOfDays.java new file mode 100644 index 0000000..401c3c1 --- /dev/null +++ b/1ano/2semestre/poo/src/tp_codecheck/tp02/NumberOfDays.java @@ -0,0 +1,27 @@ +package tp_codecheck.tp02; + +import java.util.Scanner; + +public class NumberOfDays { + public static void main(String[] args) + { + // Declare and initialize daysOfMonth + int[] daysOfMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + + Scanner in = new Scanner(System.in); + System.out.print("Month (1 - 12): "); + int month = in.nextInt(); + System.out.print("Year: "); + int year = in.nextInt(); + + if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) { + // It's a leap year. Adjust the entry for February + daysOfMonth[1]+=1; + } + + // Get the number of days in the given month + int days = daysOfMonth[month-1]; + + System.out.println("Number of days: " + days); + } +} diff --git a/1ano/2semestre/poo/src/tp_codecheck/tp02/Numbers.java b/1ano/2semestre/poo/src/tp_codecheck/tp02/Numbers.java new file mode 100644 index 0000000..ebaa91c --- /dev/null +++ b/1ano/2semestre/poo/src/tp_codecheck/tp02/Numbers.java @@ -0,0 +1,17 @@ +package tp_codecheck.tp02; + +public class Numbers { + public static void main(String[] args) { + // Different arrays will be substituted here. + int[] values = { 3, 1, 4, 1, 5, 9 }; + int[] newValues = new int[values.length/2]; + + for (int x = 0; x < values.length; x+=2) { + newValues[x/2] = values[x]; + } + + for (int i = 0; i < newValues.length; i++) { + System.out.println(newValues[i]); + } + } +}