Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.lang.*;
- import javax.swing.*;
- public class P1_3
- { public static void main(String args [ ])
- {
- double a,b,c,d,x;
- String st;
- st=JOptionPane.showInputDialog("Podaj pierwsza liczbe");
- a=Double.parseDouble(st);
- st=JOptionPane.showInputDialog("Podaj druga liczbe");
- b=Double.parseDouble(st);
- st=JOptionPane.showInputDialog("Podaj trzecia liczbe");
- c=Double.parseDouble(st);
- st=JOptionPane.showInputDialog("Podaj czwarta liczbe");
- d=Double.parseDouble(st);
- x=a*b*c*d;
- JOptionPane.showMessageDialog(null, "Iloczyn elementow: "+x, "Wynik",1);
- System.exit(0);
- }
- }
- import java.lang.*;
- import javax.swing.*;
- public class P1_4
- { public static void main(String args [ ])
- {
- int n, i;
- double a,x,sr;
- String st;
- st=JOptionPane.showInputDialog("Podaj liczbe zmiennych: ");
- n=Integer.parseInt(st);
- i=1;
- x=0;
- while (i<=n)
- {
- st=JOptionPane.showInputDialog("Podaj liczbe:");
- a=Double.parseDouble(st);
- x=x+a;
- i=i+1;
- }
- sr=x/n;
- JOptionPane.showMessageDialog(null, "Srednia z n elementow: "+sr, "Wynik",1);
- System.exit(0);
- }
- }
- import java.lang.*;
- import javax.swing.*;
- public class P1_5
- { public static void main(String args [ ])
- {
- int i;
- double min, max, oceny[]={2,2.5,5,3,3.5,4};
- String st;
- min=oceny[0];
- max=oceny[0];
- for (i=0; i<=5; i++)
- {
- if (oceny[i]<min)
- {
- min=oceny[i];
- }
- if (oceny[i]>max)
- {
- max=oceny[i];
- }
- }
- JOptionPane.showMessageDialog(null, "Najnizsza ocena: "+ min, "Wynik",1);
- JOptionPane.showMessageDialog(null, "Najwyzsza ocena: "+ max, "Wynik",1);
- System.exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement