adicionado o código de repetição
parent
cd1844c144
commit
d9c8573090
|
|
@ -1,9 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.mycompany.ciclowhile;
|
package com.mycompany.ciclowhile;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author joaomiranda
|
* @author joaomiranda
|
||||||
|
|
@ -11,6 +12,12 @@ package com.mycompany.ciclowhile;
|
||||||
public class CicloWhile {
|
public class CicloWhile {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println("Hello World!");
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue