From bc505ddb33343ed7c8faea64d0425a16a00fe9cd Mon Sep 17 00:00:00 2001 From: 250409 <250409@localhost> Date: Tue, 11 Nov 2025 11:26:25 +0000 Subject: [PATCH] while --- pom.xml | 13 ++++++++++ .../while_exercicio1/While_Exercicio1.java | 24 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 pom.xml create mode 100644 src/main/java/com/mycompany/while_exercicio1/While_Exercicio1.java diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..705c38e --- /dev/null +++ b/pom.xml @@ -0,0 +1,13 @@ + + + 4.0.0 + com.mycompany + While_Exercicio1 + 1.0-SNAPSHOT + jar + + UTF-8 + 24 + com.mycompany.while_exercicio1.While_Exercicio1 + + \ No newline at end of file diff --git a/src/main/java/com/mycompany/while_exercicio1/While_Exercicio1.java b/src/main/java/com/mycompany/while_exercicio1/While_Exercicio1.java new file mode 100644 index 0000000..64bc4d7 --- /dev/null +++ b/src/main/java/com/mycompany/while_exercicio1/While_Exercicio1.java @@ -0,0 +1,24 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.mycompany.while_exercicio1; + +import java.util.Scanner; + +/** + * + * @author 250409 + */ +public class While_Exercicio1 { + + 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("Introduza um número positivo"); + numero = scanner.nextInt(); + } + } +}