Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package bsp104MinMax;
- import java.util.Random;
- import javax.swing.JOptionPane;
- public class Bsp104MinMax
- {
- private int zz1,zz2,zz3,zz4,zz5,zz6,min,max;
- public void berechneZZ()
- {
- Random rand = new Random();
- zz1 = 10 + rand.nextInt(41);
- zz2 = 10 + rand.nextInt(41);
- zz3 = 10 + rand.nextInt(41);
- zz4 = 10 + rand.nextInt(41);
- zz5 = 10 + rand.nextInt(41);
- zz6 = 10 + rand.nextInt(41);
- }
- public void findeMin()
- {
- min = Math.min(zz1,Math.min(zz2,Math.min(zz3,Math.min(zz4,Math.min(zz5,zz6)))));
- }
- public void findeMax()
- {
- max = Math.max(zz1,Math.max(zz2,Math.max(zz3,Math.max(zz4,Math.max(zz5,zz6)))));
- }
- public void ausgabe()
- {
- String s = String.format("Zufallszahlen: %d - %d - %d - %d - %d - %d\n Größte Zahl: %d\n Kleinste Zahl: %d ",zz1,zz2,zz3,zz4,zz5,zz6,max,min);
- JOptionPane.showMessageDialog(null, s, "MinMax-Bestimmung",JOptionPane.INFORMATION_MESSAGE);
- JOptionPane.showMessageDialog(null, max, s, max);
- }
- public static void main(String[] args)
- {
- Bsp104MinMax m = new Bsp104MinMax();
- m.berechneZZ();
- m.findeMax();
- m.findeMax();
- m.ausgabe();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement