Advertisement
Guest User

lab2

a guest
Oct 15th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.33 KB | None | 0 0
  1. package lab2;
  2. import javax.swing.JOptionPane;
  3. import java.util.Scanner;
  4. import java.util.Arrays;
  5. import javax.swing.ImageIcon;
  6. import javax.swing.JFrame;
  7.  
  8. public class Lab2 {
  9.  
  10.        public static void main(String args[])
  11.     {
  12.             String cw1 = "\n Cwiczenie 1";
  13.             String cw2 = "\n Cwiczenie 2";
  14.             String cw3 = "\n Cwiczenie 3";
  15.             JFrame frame = new JFrame("JOptionPane showMessageDialog example");
  16.                 JOptionPane.showMessageDialog(frame, cw1, "\t Okienko informacyjne", JOptionPane.INFORMATION_MESSAGE);
  17.             String wizytowka = "****************\n" +
  18.                                "*     Eryk          *\n" +
  19.                                "*   Gilewicz     *\n" +
  20.                                "*    Wroclaw   *\n" +
  21.                                "****************";
  22.             JOptionPane.showMessageDialog(frame, wizytowka, "Wizytowka", JOptionPane.PLAIN_MESSAGE);
  23.             JOptionPane.showMessageDialog(frame, cw2, "\t Okienko informacyjne", JOptionPane.INFORMATION_MESSAGE);
  24.             Scanner reader = new Scanner(System.in);
  25.             String dane_wp = "\n Wprowadz dwie liczby: ";
  26.             JOptionPane.showMessageDialog(frame, dane_wp, "\t Okienko informacyjne", JOptionPane.INFORMATION_MESSAGE);
  27.             String liczba_1 = JOptionPane.showInputDialog(frame, "Podaj liczbe 1:");
  28.             String liczba_2 = JOptionPane.showInputDialog(frame, "Podaj liczbe 2:");
  29.             int liczba_3 = Integer.parseInt(liczba_1);
  30.             int liczba_4 = Integer.parseInt(liczba_2);
  31.             String tekst_1 = "Liczba pierwsza jest wieksza niz druga";
  32.             String tekst_2 = "Liczba druga jest wieksza niz pierwsza";
  33.             String tekst_3 = "Liczby sa rowne\n";
  34.             if(liczba_3 > liczba_4){
  35.                 JOptionPane.showMessageDialog(frame, tekst_1, "\t Wynik porownania", JOptionPane.INFORMATION_MESSAGE);
  36.             }
  37.             if(liczba_3 < liczba_4){
  38.                 JOptionPane.showMessageDialog(frame, tekst_2, "\t Wynik porownania", JOptionPane.INFORMATION_MESSAGE);
  39.             }
  40.             if(liczba_3 == liczba_4){
  41.                 JOptionPane.showMessageDialog(frame, tekst_3, "\t Wynik porownania", JOptionPane.INFORMATION_MESSAGE);
  42.             }
  43.             reader.close();
  44.             JOptionPane.showMessageDialog(frame, cw3, "\t Okienko informacyjne", JOptionPane.INFORMATION_MESSAGE);
  45.             int[] tablica = new int[]{5,3,2};
  46.             String tablica_1 = "Elementy tablicy to: ";
  47.             JOptionPane.showMessageDialog(frame, tablica_1, "\t Okienko informacyjne", JOptionPane.INFORMATION_MESSAGE);
  48.             int i=0;
  49.            
  50.             while(i< 1){
  51.                 String tablica1 = Arrays.toString(tablica);
  52.                 JOptionPane.showMessageDialog(frame, tablica1, "\t Okienko informacyjne", JOptionPane.INFORMATION_MESSAGE);
  53.                  i++;
  54.                  
  55.             }
  56.             int min = Arrays.stream(tablica).min().getAsInt();
  57.             int max = Arrays.stream(tablica).max().getAsInt();
  58.             JOptionPane.showMessageDialog(frame, max, "\t Najwieksza wartosc w tablicy", JOptionPane.INFORMATION_MESSAGE);
  59.             JOptionPane.showMessageDialog(frame, min, "\t Najmniejsza wartosc w tablicy", JOptionPane.INFORMATION_MESSAGE);
  60.             System.exit(0);
  61.             }
  62.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement