Files
UTEC-Lic_ME_2024_2025/UTC503/24-12-16/java/exercice3/src/App.java
T
Guillaume-Sanchez ff4bb12d22 initial commit
2026-05-26 13:56:03 +02:00

22 lines
799 B
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Écrire un programme demandant à lutilisateur de saisir deux valeurs numériques b et n (vérifier que n est positif) et affichant la valeur bn.
import java.util.Scanner;
public class App {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
System.out.print("Entrez le premier chiffre que vous voulez (b) : ");
int b = sc.nextInt();
int n;
do{
System.out.print("Entrez le second chiffre que vous voulez (n), il doit être positif : ");
n = sc.nextInt();
// Vérification à effectuer pour savoir si "n" est positif, sinon on repart au "do"
} while (n < 0);
System.out.println(b + " * " + n + " = " + b*n);
}
}