commit f4e53257a11f2c9b39a5370b8b0dea5fcc5205f3 Author: 250418 <250418@localhost> Date: Tue Nov 11 11:27:53 2025 +0000 TestWhile diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..d050feb --- /dev/null +++ b/pom.xml @@ -0,0 +1,13 @@ + + + 4.0.0 + com.mycompany + Testwhile + 1.0-SNAPSHOT + jar + + UTF-8 + 24 + com.mycompany.testwhile.Testwhile + + \ No newline at end of file diff --git a/src/main/java/com/mycompany/testwhile/Testwhile.java b/src/main/java/com/mycompany/testwhile/Testwhile.java new file mode 100644 index 0000000..459dc49 --- /dev/null +++ b/src/main/java/com/mycompany/testwhile/Testwhile.java @@ -0,0 +1,24 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.mycompany.testwhile; + +import java.util.Scanner; + +/** + * + * @author 250418 + */ +public class Testwhile { + + 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(); + } + } +}