diff --git a/1ano/2semestre/poo/aula02/POO-2021-aula02.pdf b/1ano/2semestre/poo/aula02/POO-2021-aula02.pdf new file mode 100644 index 0000000..2861f1c Binary files /dev/null and b/1ano/2semestre/poo/aula02/POO-2021-aula02.pdf differ diff --git a/1ano/2semestre/poo/aula02/out/production/aula02/AverageSpeed.class b/1ano/2semestre/poo/aula02/out/production/aula02/AverageSpeed.class new file mode 100644 index 0000000..ec2c11b Binary files /dev/null and b/1ano/2semestre/poo/aula02/out/production/aula02/AverageSpeed.class differ diff --git a/1ano/2semestre/poo/aula02/out/production/aula02/CelciusToFahrenheit.class b/1ano/2semestre/poo/aula02/out/production/aula02/CelciusToFahrenheit.class new file mode 100644 index 0000000..b28c6d5 Binary files /dev/null and b/1ano/2semestre/poo/aula02/out/production/aula02/CelciusToFahrenheit.class differ diff --git a/1ano/2semestre/poo/aula02/out/production/aula02/Countdown.class b/1ano/2semestre/poo/aula02/out/production/aula02/Countdown.class new file mode 100644 index 0000000..6fe3a3d Binary files /dev/null and b/1ano/2semestre/poo/aula02/out/production/aula02/Countdown.class differ diff --git a/1ano/2semestre/poo/aula02/out/production/aula02/DistanceBetweenPoints.class b/1ano/2semestre/poo/aula02/out/production/aula02/DistanceBetweenPoints.class new file mode 100644 index 0000000..cadacdc Binary files /dev/null and b/1ano/2semestre/poo/aula02/out/production/aula02/DistanceBetweenPoints.class differ diff --git a/1ano/2semestre/poo/aula02/out/production/aula02/EnergyToHeatWater.class b/1ano/2semestre/poo/aula02/out/production/aula02/EnergyToHeatWater.class new file mode 100644 index 0000000..fe82902 Binary files /dev/null and b/1ano/2semestre/poo/aula02/out/production/aula02/EnergyToHeatWater.class differ diff --git a/1ano/2semestre/poo/aula02/out/production/aula02/Investment.class b/1ano/2semestre/poo/aula02/out/production/aula02/Investment.class new file mode 100644 index 0000000..82e7903 Binary files /dev/null and b/1ano/2semestre/poo/aula02/out/production/aula02/Investment.class differ diff --git a/1ano/2semestre/poo/aula02/out/production/aula02/KmToMiles.class b/1ano/2semestre/poo/aula02/out/production/aula02/KmToMiles.class new file mode 100644 index 0000000..70a38d7 Binary files /dev/null and b/1ano/2semestre/poo/aula02/out/production/aula02/KmToMiles.class differ diff --git a/1ano/2semestre/poo/aula02/out/production/aula02/PythagoreanTheorem.class b/1ano/2semestre/poo/aula02/out/production/aula02/PythagoreanTheorem.class new file mode 100644 index 0000000..1532e93 Binary files /dev/null and b/1ano/2semestre/poo/aula02/out/production/aula02/PythagoreanTheorem.class differ diff --git a/1ano/2semestre/poo/aula02/out/production/aula02/RealNumbers.class b/1ano/2semestre/poo/aula02/out/production/aula02/RealNumbers.class new file mode 100644 index 0000000..1caa9eb Binary files /dev/null and b/1ano/2semestre/poo/aula02/out/production/aula02/RealNumbers.class differ diff --git a/1ano/2semestre/poo/aula02/out/production/aula02/SecsToHMS.class b/1ano/2semestre/poo/aula02/out/production/aula02/SecsToHMS.class new file mode 100644 index 0000000..36ed6b6 Binary files /dev/null and b/1ano/2semestre/poo/aula02/out/production/aula02/SecsToHMS.class differ diff --git a/1ano/2semestre/poo/aula02/src/AverageSpeed.java b/1ano/2semestre/poo/aula02/src/AverageSpeed.java new file mode 100644 index 0000000..a4f46e2 --- /dev/null +++ b/1ano/2semestre/poo/aula02/src/AverageSpeed.java @@ -0,0 +1,32 @@ +import java.util.Scanner; + +// Solução do exercício 5 + +public class AverageSpeed { + public static void main(String[] args) { + Scanner sin = new Scanner(System.in); + System.out.println("v1? "); + double v1; + do { + v1 = sin.nextDouble(); + } while (v1 <= 0); + System.out.println("d1? "); + double d1; + do { + d1 = sin.nextDouble(); + } while (d1 <= 0); + System.out.println("v2? "); + double v2; + do { + v2 = sin.nextDouble(); + } while (v2 <= 0); + System.out.println("d2? "); + double d2; + do { + d2 = sin.nextDouble(); + } while (d2 <= 0); + + double vm = (d1 + d2) / ((d1 / v1) + (d2 / v2)); + System.out.printf("Velocidade final da viagem: %fkm/h", vm); + } +} diff --git a/1ano/2semestre/poo/aula02/src/CelciusToFahrenheit.java b/1ano/2semestre/poo/aula02/src/CelciusToFahrenheit.java new file mode 100644 index 0000000..c92ce4e --- /dev/null +++ b/1ano/2semestre/poo/aula02/src/CelciusToFahrenheit.java @@ -0,0 +1,13 @@ +import java.util.Scanner; + +// Solução do exercício 2 + +public class CelciusToFahrenheit { + public static void main(String[] args) { + System.out.print("ºC? "); + Scanner sin = new Scanner(System.in); + double celcius = sin.nextDouble(); + double fahrenheit = 1.8*celcius+32; + System.out.printf("%fºC = %fºF", celcius, fahrenheit); + } +} diff --git a/1ano/2semestre/poo/aula02/src/Countdown.java b/1ano/2semestre/poo/aula02/src/Countdown.java new file mode 100644 index 0000000..2e4b19c --- /dev/null +++ b/1ano/2semestre/poo/aula02/src/Countdown.java @@ -0,0 +1,15 @@ +import java.util.Scanner; + +// Solução do exercício 9 + +public class Countdown { + public static void main(String[] args){ + Scanner sin = new Scanner(System.in); + + System.out.print("N? "); + int n = sin.nextInt(); + for (int i = n; i >= 0; i--) { + System.out.print(i%10 == 0 ? i + "\n" : i + ","); + } + } +} \ No newline at end of file diff --git a/1ano/2semestre/poo/aula02/src/DistanceBetweenPoints.java b/1ano/2semestre/poo/aula02/src/DistanceBetweenPoints.java new file mode 100644 index 0000000..ea6d923 --- /dev/null +++ b/1ano/2semestre/poo/aula02/src/DistanceBetweenPoints.java @@ -0,0 +1,20 @@ +import java.util.Scanner; + +// Solução do exercício 7 + +public class DistanceBetweenPoints { + public static void main(String[] args){ + Scanner sin = new Scanner(System.in); + + System.out.print("Coordenadas do ponto 1 (separadas por ','): "); + String[] p1 = sin.next().split(","); + System.out.print("Coordenadas do ponto 2 (separadas por ','): "); + String[] p2 = sin.next().split(","); + + double distance = Math.sqrt( + Math.pow(Double.parseDouble(p1[0]) - Double.parseDouble(p2[0]), 2) + + Math.pow(Double.parseDouble(p1[1]) - Double.parseDouble(p2[1]), 2)); + + System.out.printf("A distância entre os dois pontos é %f", distance); + } +} \ No newline at end of file diff --git a/1ano/2semestre/poo/aula02/src/EnergyToHeatWater.java b/1ano/2semestre/poo/aula02/src/EnergyToHeatWater.java new file mode 100644 index 0000000..ba219f3 --- /dev/null +++ b/1ano/2semestre/poo/aula02/src/EnergyToHeatWater.java @@ -0,0 +1,17 @@ +import java.util.Scanner; + +// Solução do exercício 3 + +public class EnergyToHeatWater { + public static void main(String[] args) { + Scanner sin = new Scanner(System.in); + System.out.print("Kg de água? "); + double kgOfWater = sin.nextDouble(); + System.out.print("Temperatura inicial da água (ºC)? "); + double initialTemperature = sin.nextDouble(); + System.out.print("Temperatura final da água (ºC)? "); + double finalTemperature = sin.nextDouble(); + double energy = kgOfWater * (finalTemperature - initialTemperature) * 4184; + System.out.printf("Para aquecer %fkg de água de %fºC para %fºC, serão necessários %fJ de energia.", kgOfWater, initialTemperature, finalTemperature, energy); + } +} diff --git a/1ano/2semestre/poo/aula02/src/Investment.java b/1ano/2semestre/poo/aula02/src/Investment.java new file mode 100644 index 0000000..a386180 --- /dev/null +++ b/1ano/2semestre/poo/aula02/src/Investment.java @@ -0,0 +1,15 @@ +import java.util.Scanner; + +// Solução do exercício 4 + +public class Investment { + public static void main(String[] args) { + Scanner sin = new Scanner(System.in); + System.out.print("Saldo inicial (Euros)? "); + double initialWallet = sin.nextDouble(); + System.out.print("Taxa de juro mensal (%)? "); + double tax = sin.nextDouble(); + double finalWallet = initialWallet * Math.pow(1 + tax/100, 3); + System.out.printf("O saldo final será de %f euros", finalWallet); + } +} diff --git a/1ano/2semestre/poo/aula02/src/KmToMiles.java b/1ano/2semestre/poo/aula02/src/KmToMiles.java new file mode 100644 index 0000000..947d387 --- /dev/null +++ b/1ano/2semestre/poo/aula02/src/KmToMiles.java @@ -0,0 +1,13 @@ +import java.util.Scanner; + +// Solução do exercício 1 + +public class KmToMiles { + public static void main(String[] args) { + System.out.print("Km? "); + Scanner sin = new Scanner(System.in); + double km = sin.nextDouble(); + double miles = km / 1.609; + System.out.printf("%fkm = %f miles", km, miles); + } +} \ No newline at end of file diff --git a/1ano/2semestre/poo/aula02/src/PythagoreanTheorem.java b/1ano/2semestre/poo/aula02/src/PythagoreanTheorem.java new file mode 100644 index 0000000..08db3b4 --- /dev/null +++ b/1ano/2semestre/poo/aula02/src/PythagoreanTheorem.java @@ -0,0 +1,28 @@ +import java.util.Scanner; + +// Solução do exercício 8 + +public class PythagoreanTheorem { + public static void main(String[] args){ + Scanner sin = new Scanner(System.in); + + System.out.println("Cateto A:"); + double a; + do { + a = sin.nextDouble(); + } while (a <= 0); + System.out.println("Cateto B:"); + double b; + do { + b = sin.nextDouble(); + } while (b <= 0); + + double c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)); + + double cossin = a / c; + double angRad = Math.acos(cossin); + double angDeg = angRad * 180 / Math.PI; + + System.out.printf("O comprimento da hipotenusa é %f e o valor do angulo entre o cateto A e a hipotenusa é %f°", (float) (Math.round(c * 100) / 100), (float) (Math.round(angDeg * 100) / 100)); + } +} \ No newline at end of file diff --git a/1ano/2semestre/poo/aula02/src/RealNumbers.java b/1ano/2semestre/poo/aula02/src/RealNumbers.java new file mode 100644 index 0000000..8a6b6b1 --- /dev/null +++ b/1ano/2semestre/poo/aula02/src/RealNumbers.java @@ -0,0 +1,31 @@ +import java.util.Scanner; + +// Solução do exercício 10 + +public class RealNumbers { + public static void main(String[] args){ + Scanner sin = new Scanner(System.in); + + int readNumbers = 1; + + System.out.println("Introduza os diversos números."); + double first = sin.nextDouble(); + double max = first; + double min = first; + double sum = first; + + while (true) { + double n = sin.nextDouble(); + if (n == first) + break; + if (n > max) + max = n; + if (n < min) + min = n; + sum += n; + ++readNumbers; + } + + System.out.printf("Valor máximo: %f\nValor mínimo: %f\nMédia: %f\nTotal: %f", max, min, (float) sum/readNumbers, sum); + } +} \ No newline at end of file diff --git a/1ano/2semestre/poo/aula02/src/SecsToHMS.java b/1ano/2semestre/poo/aula02/src/SecsToHMS.java new file mode 100644 index 0000000..bc1e1b0 --- /dev/null +++ b/1ano/2semestre/poo/aula02/src/SecsToHMS.java @@ -0,0 +1,20 @@ +import java.util.Scanner; + +// Solução do exercício 6 + +public class SecsToHMS { + public static void main(String[] args){ + Scanner sin = new Scanner(System.in); + + System.out.println("Introduza os segundos totais: "); + int totalSecs; + do { + totalSecs = sin.nextInt(); + } while (totalSecs <= 0); + int secs = totalSecs % 60; + int mins = Math.round((float) (totalSecs / 60)); + int hours = Math.round((float) (mins / 60)); + mins = mins % 60; + System.out.printf("%d segundos no formato hh:mm:ss : %d:%d:%d", totalSecs, hours, mins, secs); + } +} \ No newline at end of file diff --git a/1ano/2semestre/poo/slides/POO_01_Introdução.pdf b/1ano/2semestre/poo/slides/POO_01_Introdução.pdf new file mode 100644 index 0000000..664dce1 Binary files /dev/null and b/1ano/2semestre/poo/slides/POO_01_Introdução.pdf differ diff --git a/1ano/2semestre/poo/slides/POO_02_ControloFluxo.pdf b/1ano/2semestre/poo/slides/POO_02_ControloFluxo.pdf new file mode 100644 index 0000000..b6dfe22 Binary files /dev/null and b/1ano/2semestre/poo/slides/POO_02_ControloFluxo.pdf differ