17 lines
508 B
Java
17 lines
508 B
Java
// Escribir un algoritmo que lee un número entero positivo y seguidamente escribe el carácter
|
|
// “*”, un número de veces igual al valor numérico leído. En aquellos casos en que el valor
|
|
// leído no sea positivo se deberá escribir un único asterisco.
|
|
|
|
import java.util.Scanner;
|
|
|
|
void main() {
|
|
Scanner sc = new Scanner(System.in);
|
|
System.out.println("Introduce un número: ");
|
|
int input = sc.nextInt();
|
|
sc.close();
|
|
do {
|
|
System.out.print("*");
|
|
} while(--input > 0);
|
|
System.out.println();
|
|
}
|