Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Querprodukt {
- public static void main (String[] args) {
- System.out.println("Bitte geben Sie eine Zahl ein: ");
- Scanner scanner = new Scanner(System.in);
- boolean b = false;
- int querprodukt = 1;
- int q;
- while (b = false) {
- q = scanner.nextInt();
- int ausgabe = q;
- if (q>=1 && q<=1000000) {
- b = true;
- }
- else {
- System.out.println("FEHLER - Zahl ungültig");
- }
- while (q>0) {
- int rest = q%10;
- querprodukt = querprodukt*rest;
- q = q/10;
- }
- System.out.println("Das Querprodukt für: "+ausgabe+" ist: "+querprodukt);
- }
- scanner.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement