Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lab2;
- import javax.swing.JOptionPane;
- import java.util.Scanner;
- import java.util.Arrays;
- import javax.swing.ImageIcon;
- import javax.swing.JFrame;
- public class Lab2 {
- public static void main(String args[])
- {
- String cw1 = "\n Cwiczenie 1";
- String cw2 = "\n Cwiczenie 2";
- String cw3 = "\n Cwiczenie 3";
- JFrame frame = new JFrame("JOptionPane showMessageDialog example");
- JOptionPane.showMessageDialog(frame, cw1, "\t Okienko informacyjne", JOptionPane.INFORMATION_MESSAGE);
- String wizytowka = "****************\n" +
- "* Eryk *\n" +
- "* Gilewicz *\n" +
- "* Wroclaw *\n" +
- "****************";
- JOptionPane.showMessageDialog(frame, wizytowka, "Wizytowka", JOptionPane.PLAIN_MESSAGE);
- JOptionPane.showMessageDialog(frame, cw2, "\t Okienko informacyjne", JOptionPane.INFORMATION_MESSAGE);
- Scanner reader = new Scanner(System.in);
- String dane_wp = "\n Wprowadz dwie liczby: ";
- JOptionPane.showMessageDialog(frame, dane_wp, "\t Okienko informacyjne", JOptionPane.INFORMATION_MESSAGE);
- String liczba_1 = JOptionPane.showInputDialog(frame, "Podaj liczbe 1:");
- String liczba_2 = JOptionPane.showInputDialog(frame, "Podaj liczbe 2:");
- int liczba_3 = Integer.parseInt(liczba_1);
- int liczba_4 = Integer.parseInt(liczba_2);
- String tekst_1 = "Liczba pierwsza jest wieksza niz druga";
- String tekst_2 = "Liczba druga jest wieksza niz pierwsza";
- String tekst_3 = "Liczby sa rowne\n";
- if(liczba_3 > liczba_4){
- JOptionPane.showMessageDialog(frame, tekst_1, "\t Wynik porownania", JOptionPane.INFORMATION_MESSAGE);
- }
- if(liczba_3 < liczba_4){
- JOptionPane.showMessageDialog(frame, tekst_2, "\t Wynik porownania", JOptionPane.INFORMATION_MESSAGE);
- }
- if(liczba_3 == liczba_4){
- JOptionPane.showMessageDialog(frame, tekst_3, "\t Wynik porownania", JOptionPane.INFORMATION_MESSAGE);
- }
- reader.close();
- JOptionPane.showMessageDialog(frame, cw3, "\t Okienko informacyjne", JOptionPane.INFORMATION_MESSAGE);
- int[] tablica = new int[]{5,3,2};
- String tablica_1 = "Elementy tablicy to: ";
- JOptionPane.showMessageDialog(frame, tablica_1, "\t Okienko informacyjne", JOptionPane.INFORMATION_MESSAGE);
- int i=0;
- while(i< 1){
- String tablica1 = Arrays.toString(tablica);
- JOptionPane.showMessageDialog(frame, tablica1, "\t Okienko informacyjne", JOptionPane.INFORMATION_MESSAGE);
- i++;
- }
- int min = Arrays.stream(tablica).min().getAsInt();
- int max = Arrays.stream(tablica).max().getAsInt();
- JOptionPane.showMessageDialog(frame, max, "\t Najwieksza wartosc w tablicy", JOptionPane.INFORMATION_MESSAGE);
- JOptionPane.showMessageDialog(frame, min, "\t Najmniejsza wartosc w tablicy", JOptionPane.INFORMATION_MESSAGE);
- System.exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement