From 7ccf231244a9e9a744838998596962ccd1bbb662 Mon Sep 17 00:00:00 2001 From: TiagoRG <35657250+TiagoRG@users.noreply.github.com> Date: Mon, 20 Feb 2023 13:45:49 +0000 Subject: [PATCH] POO tp_codecheck finished --- .../poo/tp_codecheck/tp02/Array1.md | 23 +++++++++++++++ .../poo/tp_codecheck/tp02/NumberOfDays.class | Bin 0 -> 1536 bytes .../poo/tp_codecheck/tp02/Numbers.class | Bin 0 -> 753 bytes .../poo/src/tp_codecheck/tp02/Array1.md | 23 +++++++++++++++ .../src/tp_codecheck/tp02/NumberOfDays.java | 27 ++++++++++++++++++ .../poo/src/tp_codecheck/tp02/Numbers.java | 17 +++++++++++ 6 files changed, 90 insertions(+) create mode 100644 1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/Array1.md create mode 100644 1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/NumberOfDays.class create mode 100644 1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/Numbers.class create mode 100644 1ano/2semestre/poo/src/tp_codecheck/tp02/Array1.md create mode 100644 1ano/2semestre/poo/src/tp_codecheck/tp02/NumberOfDays.java create mode 100644 1ano/2semestre/poo/src/tp_codecheck/tp02/Numbers.java 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 0000000000000000000000000000000000000000..dbb0162226592552ba3796b68a68bf3615643728 GIT binary patch literal 1536 zcmaJ>-*4Mg6#j1G7S=&CI<|~s`6W5Upshghf$!&&2zR=`IGh`#Dk@R|{h9i964QHVv!(kXW zg}GNy8snjK`wTOl&ycG{kzP=$`h$^d$j}x2vJMVY<r5{SS~bGl@|9|g}BnQ_vO7}N-yxKyO z>>@lQq{S1=44F37W*0b9O7Kq?Ea0x44qhN-|SQG$Vx>Yi1*j9$7Oa*M0|YJ;UsC z%-5e`VPWYAr>`7gWm{d|np`%uoW=(~Ba_q2Hl0RJ%d#Ix(ATuDirUxq+Ig*A+)PqT zF8Knhz!CDQu>@3OMP#BTcIkXbt$j%!z&*_25cB9Gi|??A@3D*@>D~SXXCnf(<0kPw zu2bwT#cbjRQScBpMSnny?%@tT#1`e~lUJD}jS%K=lcXd*qNpV#{=v6Ma%^+l;@~uS fq*D~}FlC>6 zOStq52ar&e58yBO0k|X7^6cb-RBZ3g&YL&0Z+89t{M!`3Gt@LlkX0x;Qb-Hr5A0*x z@au0nMB@h!jTe() z-wlt*+Gapt!Sn)m2EMlYK9Pbsa%{hAhhFT@K_%Mvn6zU4w_=+mhqlN4%eB2(8_9XF z2QL`3>sSgj-%WO|Uhi(22ChaTa z6RD5bSrsMRM1|Q;DRMPgQ6g^PHtVc1cMa=oU;{1O;Yz|?;$;x~$aAZSYD JZ89pM`WK9}nQ#CA literal 0 HcmV?d00001 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]); + } + } +}