TestWhile

This commit is contained in:
250418
2025-11-11 11:27:53 +00:00
commit f4e53257a1
2 changed files with 37 additions and 0 deletions

View File

@@ -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();
}
}
}