From cafc0530a5b133ffd19c1777c2ee12d423a6c9fb Mon Sep 17 00:00:00 2001 From: 250408 <250408@localhost> Date: Tue, 11 Nov 2025 11:22:16 +0000 Subject: [PATCH] while --- pom.xml | 12 +++++++ .../com/mycompany/whiletest/WhileTest.java | 35 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 pom.xml create mode 100644 src/main/java/com/mycompany/whiletest/WhileTest.java diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..ab3ba0c --- /dev/null +++ b/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + com.mycompany + whileTest + 1.0-SNAPSHOT + jar + + UTF-8 + 24 + + \ No newline at end of file diff --git a/src/main/java/com/mycompany/whiletest/WhileTest.java b/src/main/java/com/mycompany/whiletest/WhileTest.java new file mode 100644 index 0000000..1fa78a2 --- /dev/null +++ b/src/main/java/com/mycompany/whiletest/WhileTest.java @@ -0,0 +1,35 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.mycompany.whiletest; + +import java.util.Scanner; + +/** + * + * @author 250408 + */ +public class WhileTest { + + 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(); +} + } +} + + + + + +