From 05a04d0717a94ed2fb748ec22511992a107ae336 Mon Sep 17 00:00:00 2001 From: TiagoRG <35657250+TiagoRG@users.noreply.github.com> Date: Mon, 20 Feb 2023 12:03:10 +0000 Subject: [PATCH] POO tp_codecheck added --- .../out/production/poo/aula02/SecsToHMS.class | Bin 1218 -> 1244 bytes .../poo/tp_codecheck/tp01/BankInterest.class | Bin 0 -> 1560 bytes .../poo/tp_codecheck/tp01/Table.class | Bin 0 -> 1218 bytes .../poo/tp_codecheck/tp01/Temperature.class | Bin 0 -> 1136 bytes .../poo/tp_codecheck/tp02/Strings1.md | 9 +++ .../poo/tp_codecheck/tp02/Words.class | Bin 0 -> 1376 bytes .../src/tp_codecheck/tp01/BankInterest.java | 59 ++++++++++++++++++ .../poo/src/tp_codecheck/tp01/Table.java | 28 +++++++++ .../src/tp_codecheck/tp01/Temperature.java | 29 +++++++++ .../poo/src/tp_codecheck/tp02/Strings1.md | 9 +++ .../poo/src/tp_codecheck/tp02/Words.java | 12 ++++ 11 files changed, 146 insertions(+) create mode 100644 1ano/2semestre/poo/out/production/poo/tp_codecheck/tp01/BankInterest.class create mode 100644 1ano/2semestre/poo/out/production/poo/tp_codecheck/tp01/Table.class create mode 100644 1ano/2semestre/poo/out/production/poo/tp_codecheck/tp01/Temperature.class create mode 100644 1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/Strings1.md create mode 100644 1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/Words.class create mode 100644 1ano/2semestre/poo/src/tp_codecheck/tp01/BankInterest.java create mode 100644 1ano/2semestre/poo/src/tp_codecheck/tp01/Table.java create mode 100644 1ano/2semestre/poo/src/tp_codecheck/tp01/Temperature.java create mode 100644 1ano/2semestre/poo/src/tp_codecheck/tp02/Strings1.md create mode 100644 1ano/2semestre/poo/src/tp_codecheck/tp02/Words.java diff --git a/1ano/2semestre/poo/out/production/poo/aula02/SecsToHMS.class b/1ano/2semestre/poo/out/production/poo/aula02/SecsToHMS.class index d09e42072ad1d64840e89572b7c6949fbe3b71ef..e78b87b5aa57a371a5392c8ecafb915051124973 100644 GIT binary patch delta 248 zcmX@ad54qh)W2Q(7#JAr8GJW#RWONiF|ae3^DtO2urV^QCgSlS8)M19 z1XRZWB!MyvY(UZ)$kPYXj6j-IYdZtuMzFLEkOWCHFmN*10!bc-0tP#vB_J^e21lR> zNb@V8IyNAkHTfQMs-X5Z1~Y^SS`1v116Y)UMHw;~#K7j*LDVuhF*pPDa5Ka+xG=Z^ vO_F2?WN>3}2RclS!H2;E$YN&D0IKo?vRD|58O#~HfGk#^N^hV(CI%k>afcqq delta 222 zcmcb^d5Dwi)W2Q(7#JAr8N4=fRWLELGnh}F&h$6NjDZO#$^ax88CV(EfTRVGrw^nV zfi$bub_T|cU};Mr36f@D;AF4@k~|Ov4Au-bU@=<;JD>t3?9mrw@s`LQrV`A_G0B_G4C;$Ke diff --git a/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp01/BankInterest.class b/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp01/BankInterest.class new file mode 100644 index 0000000000000000000000000000000000000000..0651117c1c3623c3f78d1169dff9ab0663f1382b GIT binary patch literal 1560 zcmaJ>OK%%h7(Lgoi660XJ$0QzgHuSc3yIUv0+XbTlh|z>oTiOKO4>p+8K%kPF?OAC zp%S|agjA^@Bt%sKLISBQ*w95h@}GZe`sx9D%@?Wn0cE0dFR|7{~`0$0v|? zH-aCvCJN;LTz63*|63dU{GMwGLdAXs$p{W0^+=J*^=-%8V(w~#rS_NI@>Vr>u5Q^* z#i^V6)@T7p2p)5j=+hfsk#!E zjja{4zM#9!?<-dgeREN-Tk_m8`kXauTOeKj|Fo3Ax24N#NoG3v?%t{^^qZ5-IS~*A z2I%!wrcUhPFQ819mggrHibS)8HY(4xQ1D`LzKxYaadLTT`iwvqW6Gu3(gGoa+K^E# z7;?i}heT7>&KYADN^6t_x+{)uY|QF4R|y4Wwos`y>V|pRlCu);lyy+fE2k>Y?^iw^ za8MB7I>}RxyWs9WdLQB&_w^K4`5K6$z%|lzKoO^T3gQf=X<@K<2n8wHzEUZQir`F4 z^G7vBMOX`}=+?q2Vp_L~xE70Q@q0+@>)FBM-=S~m9-g|7XGRh|i5(o()Rap1k3U0H zg24?fc^4BB#@eR{}&($ANMZy5JnH8IEVx%KZQg5_2Mx9DEhe$aMf^x0uG`?!4@!t*KiDL z7{*mRkGF9gH*f;C_}zU-&%6BYq;6kRzw@kD!VD{!yXg8Zy19#}AzntAQ9gW$Sw?VB z@Hx&BdCBfm%n|v?@ea-rDP;N)v(NB8QuqM#L}9YNi3(9SS-(r3Gl-G<4ZK1WC$lO~ ui;T>Z`vuxm@=dn*y~^5Y`2S&8M8T4`{V3@30*OTYFL=FVb&-A^T>2LTSW8*} literal 0 HcmV?d00001 diff --git a/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp01/Table.class b/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp01/Table.class new file mode 100644 index 0000000000000000000000000000000000000000..15ff93c5afca36dddf81228ff8036cb033d9ac24 GIT binary patch literal 1218 zcmZ`(+fEZv6kVsCcFH*12BC$D77=MtsemZhiV9WR1TRSqhWKEHaoP^HQ&OfF6CaH} z`4v3yX!Jpe34VZo;UDT-6`GDC(Eo8SKHK)}8olaG1`V$IiJW@+ zUc+&{qSvs^S|)-X0b^o2@jTJFXc6=Y2sZ*lAdsg#DiEsH%L%GO0$ScpoJ;t74KWO> z7|{{OF@b?Ysu1y(tXUGsCR;FkKE&X-<;=qlQ;T9Ibtu>%dY7+hIDv$UF&!r{E)ey$ z9$EFrwpFpMCuwi%{7m}3xly$RA{DbytGkXRpd<^aoQ4UURxzm~iIhOk-@e{9y$ahz zI?^?l%0+NSAU5$>c4d05)F~EAnuc?jR*}|m9y0>{e-jm4&o0{y0d>c$HtoA4JjBu+ z{MsHF4Rg4lVqWIB_|MdG^`;MhkU%;DTjmS_u8^%j@2cb4cbc^gyV2%rtkx~Fx@I;U z$-iw>yo$3eFueMoHpzrF({Uxx&N;M4lUn2W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+qA3*q@6MTq_! literal 0 HcmV?d00001 diff --git a/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/Strings1.md b/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/Strings1.md new file mode 100644 index 0000000..ea8d514 --- /dev/null +++ b/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/Strings1.md @@ -0,0 +1,9 @@ +# Tabela Exercício 1 de Strings + +| Question | Answer | +|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------| +| What is the length of the string below?
String str = "Java Program" | 12 | +| With str as defined above, give a call to the substring method that returns the substring "gram". | str.substring(8) | +| Use the string concatenation operator to change the string variable str to contain the string "Java Programming". | str += "ming" | +| What does the following statement sequence print?

String str = "Harry";
int n = str.length();
String mystery = str.substring(0, 1) + str.substring(n - 1, n);
System.out.println(mystery); | Hy | +| Consider the following statement sequence. If the user provides the input John Q. Public, what is printed? If an error occurs, type error.

Scanner in = new Scanner(System.in);
String first = in.next();
String last = in.next();
System.out.println(last + ", " + first); | Q., John | \ No newline at end of file diff --git a/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/Words.class b/1ano/2semestre/poo/out/production/poo/tp_codecheck/tp02/Words.class new file mode 100644 index 0000000000000000000000000000000000000000..aa879395951c51270b2ed0334610ec71ca378c27 GIT binary patch literal 1376 zcmaJ>>rN9v6#k|yERLlhx|HAHlDpp&8RkRNf=;cmg) zIXD!SWawP6U0bd)gpGJkLl;AT&8aGF$IM#Xb%o!JD0(#LIK>Zlv8csR6^rAW-v=Uy(*Dv z=5Ch`+RWV?<~5i)7VwZ^@FKr0J`7q#ML6mL8tHA#n7Y(QL|RrpTV7sRMPZdpSy@;# z_dP#Pq$4R(GxTO`S8P|y2g2Xu2M%clGM>eq9QSP{HM}POrkaShd*qdbSqHA)?*_M|=N~hCZ_RAOu@1V)-Mk}$ zsf_29s+HtbhAo;)fqTal(Z; $100,000.00 2.75 % $ 0.00 + > $25,000.00 2.00 % $ 0.00 + > $10,000.00 1.00 % $ 0.00 + >= $0.00 0.00 % $ 0.00 + < $0.00 0.00 % $ 25.00 + and prints out the new balance. +*/ +public class BankInterest +{ + public static void main(String[] args) + { + // Define constants + final double HI_RATE = 2.75; + final double MD_RATE = 2.00; + final double LO_RATE = 1.00; + final double ZERO_RATE = 0.00; + final double DEB_CHG = -25.00; + + final double HI_LIMIT = 100000.00; + final double MD_LIMIT = 25000.00; + final double LO_LIMIT = 10000.00; + final double ZERO_LIMIT = 0.00; + + // Print prompt to enter a current balence + System.out.print("Enter current balance: "); + + // Read balance + Scanner in = new Scanner(System.in); + double balance = in.nextDouble(); + + // Determine interest rate (or charge) based on current balance + // to compute new balance + + // Your work here + + double newBalance; + if (balance > HI_LIMIT) + newBalance = balance*(1+HI_RATE/100); + else if (balance > MD_LIMIT) + newBalance = balance*(1+MD_RATE/100); + else if (balance > LO_LIMIT) + newBalance = balance*(1+LO_RATE/100); + else if (balance < ZERO_LIMIT) + newBalance = balance+DEB_CHG; + else + newBalance = balance; + + System.out.printf("%.2f\n", newBalance); + } +} \ No newline at end of file diff --git a/1ano/2semestre/poo/src/tp_codecheck/tp01/Table.java b/1ano/2semestre/poo/src/tp_codecheck/tp01/Table.java new file mode 100644 index 0000000..07fc547 --- /dev/null +++ b/1ano/2semestre/poo/src/tp_codecheck/tp01/Table.java @@ -0,0 +1,28 @@ +package tp_codecheck.tp01; + +// Solução do exercício 3 + +public class Table { + + public static void main(String[] args) { + System.out.printf("%s | %s | %s | %s\n", "n", "Hn", "log n", "Hn - log n"); + int n = 1; + while (n <= 1000000) { + double f1 = harmonic(n); + double f2 = Math.log((double)n); + System.out.printf("%d | %.3f | %.3f | %.9f\n", n, f1, f2, f1-f2); + n *= 2; + } + } + + /** + * Computes the Harmonic number Hn = 1 + 1/2 + 1/3 + ... + 1/n. + */ + private static double harmonic(int n) { + double sum = 0; + for (int i = 1; i <= n; i++) { + sum += 1/(float)i; + } + return sum; + } +} diff --git a/1ano/2semestre/poo/src/tp_codecheck/tp01/Temperature.java b/1ano/2semestre/poo/src/tp_codecheck/tp01/Temperature.java new file mode 100644 index 0000000..abb7a6c --- /dev/null +++ b/1ano/2semestre/poo/src/tp_codecheck/tp01/Temperature.java @@ -0,0 +1,29 @@ +package tp_codecheck.tp01; + +// Solução do exercício 1 + +/* +This is a short Java program to convert +a temperature from Celsius to Fahrenheit. +*/ + +// You may want to import stuff here... + +import java.util.Scanner; + +public class Temperature { + // Create a Scanner to parse standard input: + private static Scanner sc = new Scanner(System.in); + + public static void main(String[] args) { + // Put your code here + System.out.print("Celsius? "); + double celcius = sc.nextDouble(); + double fahrenheit = 1.8*celcius+32; + System.out.printf("%f C = %f F\n", celcius, fahrenheit); + + System.out.println("THE END"); + } +} + +// JMR 2023 \ No newline at end of file diff --git a/1ano/2semestre/poo/src/tp_codecheck/tp02/Strings1.md b/1ano/2semestre/poo/src/tp_codecheck/tp02/Strings1.md new file mode 100644 index 0000000..ea8d514 --- /dev/null +++ b/1ano/2semestre/poo/src/tp_codecheck/tp02/Strings1.md @@ -0,0 +1,9 @@ +# Tabela Exercício 1 de Strings + +| Question | Answer | +|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------| +| What is the length of the string below?
String str = "Java Program" | 12 | +| With str as defined above, give a call to the substring method that returns the substring "gram". | str.substring(8) | +| Use the string concatenation operator to change the string variable str to contain the string "Java Programming". | str += "ming" | +| What does the following statement sequence print?

String str = "Harry";
int n = str.length();
String mystery = str.substring(0, 1) + str.substring(n - 1, n);
System.out.println(mystery); | Hy | +| Consider the following statement sequence. If the user provides the input John Q. Public, what is printed? If an error occurs, type error.

Scanner in = new Scanner(System.in);
String first = in.next();
String last = in.next();
System.out.println(last + ", " + first); | Q., John | \ No newline at end of file diff --git a/1ano/2semestre/poo/src/tp_codecheck/tp02/Words.java b/1ano/2semestre/poo/src/tp_codecheck/tp02/Words.java new file mode 100644 index 0000000..d2fdf36 --- /dev/null +++ b/1ano/2semestre/poo/src/tp_codecheck/tp02/Words.java @@ -0,0 +1,12 @@ +package tp_codecheck.tp02; + +import java.util.Scanner; + +public class Words { + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + String word = in.next(); + word = word.charAt(word.length()-1) + word.substring(1, word.length()-1) + word.charAt(0); + System.out.println(word); + } +}