Exercicios for

master
250409 2025-11-18 11:44:45 +00:00
commit 60b8b46ad4
2 changed files with 97 additions and 0 deletions

13
pom.xml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>for_exercicio15</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>24</maven.compiler.release>
<exec.mainClass>com.mycompany.for_exercicio15.For_exercicio15</exec.mainClass>
</properties>
</project>

View File

@ -0,0 +1,84 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
*/
package com.mycompany.for_exercicio15;
/**
*
* @author 250409
*/
/*public class For_exercicio15 {
public static void main(String[] args) {
for(int i = 2; i <= 1000; i++)
{
boolean primo = true;
for(int j = 2; j < i; j++)
{
if (i % j == 0)
{
primo = false;
break;
}
}
if(primo)
{
System.out.println(i);
}
}
}
}
*/
/*public class For_exercicio14 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Introduza um número positivo");
int numero = scanner.nextInt();
while(numero <= 0)
{
System.out.println("Número inválido. Introduza novamente");
numero = scanner.nextInt();
}
for(int i = 0; i < numero; i++)
{
if(i % 2 != 0)
{
System.out.println(i);
}
}
}
}
*/
/*public class For_exercicio13 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
for(int i = 0; i <= 1000; i++){
System.out.println(i);
}
}
}
*/
/*
/*public class For_exercicio2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double soma = 0;
for (int mes = 1; mes <= 12; mes++) {
System.out.print("Introduza o valor da fatura do mês ");
double fatura = scanner.nextDouble();
soma += fatura;
}
double media = soma / 12;
System.out.printf("O valor médio das faturas de eletricidade é: " + media);
}
}
*/