Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. package bsp104MinMax;
  2.  
  3. import java.util.Random;
  4. import javax.swing.JOptionPane;
  5.  
  6. public class Bsp104MinMax
  7. {
  8.     private int zz1,zz2,zz3,zz4,zz5,zz6,min,max;
  9.     public void berechneZZ()
  10.     {
  11.         Random rand = new Random();
  12.        
  13.         zz1 = 10 + rand.nextInt(41);
  14.         zz2 = 10 + rand.nextInt(41);
  15.         zz3 = 10 + rand.nextInt(41);
  16.         zz4 = 10 + rand.nextInt(41);
  17.         zz5 = 10 + rand.nextInt(41);
  18.         zz6 = 10 + rand.nextInt(41);
  19.     }
  20.    
  21.     public void findeMin()
  22.     {
  23.         min = Math.min(zz1,Math.min(zz2,Math.min(zz3,Math.min(zz4,Math.min(zz5,zz6)))));
  24.     }
  25.    
  26.     public void findeMax()
  27.     {
  28.         max = Math.max(zz1,Math.max(zz2,Math.max(zz3,Math.max(zz4,Math.max(zz5,zz6)))));
  29.     }
  30.    
  31.     public void ausgabe()
  32.     {
  33.         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);
  34.         JOptionPane.showMessageDialog(null, s, "MinMax-Bestimmung",JOptionPane.INFORMATION_MESSAGE);
  35.         JOptionPane.showMessageDialog(null, max, s, max);
  36.        
  37.     }
  38.    
  39.     public static void main(String[] args)
  40.     {
  41.         Bsp104MinMax m = new Bsp104MinMax();
  42.        
  43.         m.berechneZZ();
  44.         m.findeMax();
  45.         m.findeMax();
  46.         m.ausgabe();
  47.     }
  48.    
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement