Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication2;
- import java.util.Scanner;
- public class dowhileminmax {
- public static void main(String[] args) {
- Scanner eingabe = new Scanner(System.in);
- int eingabeZahl, anzahl, min, max;
- anzahl = 1;
- max = 1;
- min = 1;
- do {
- System.out.print(anzahl + " Wert eingeben: ");
- eingabeZahl = eingabe.nextInt();
- if (anzahl == 1){
- min = eingabeZahl;
- max = eingabeZahl;
- }
- anzahl ++;
- if (eingabeZahl > max && eingabeZahl != 0) max = eingabeZahl;
- if (eingabeZahl < min && eingabeZahl != 0) min = eingabeZahl;
- }while(eingabeZahl != 0);
- System.out.println("Es wurden " + (anzahl - 2) + " Zahlen eingegeben");
- System.out.println("Maximum war " + max);
- System.out.println("Minumim war " + min);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement