Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. import java.lang.*;
  2. import javax.swing.*;
  3. public class P1_3
  4. { public static void main(String args [ ])
  5. {
  6. double a,b,c,d,x;
  7. String st;
  8.  
  9. st=JOptionPane.showInputDialog("Podaj pierwsza liczbe");
  10. a=Double.parseDouble(st);
  11.  
  12. st=JOptionPane.showInputDialog("Podaj druga liczbe");
  13. b=Double.parseDouble(st);
  14.  
  15. st=JOptionPane.showInputDialog("Podaj trzecia liczbe");
  16. c=Double.parseDouble(st);
  17.  
  18. st=JOptionPane.showInputDialog("Podaj czwarta liczbe");
  19. d=Double.parseDouble(st);
  20.  
  21. x=a*b*c*d;
  22.  
  23. JOptionPane.showMessageDialog(null, "Iloczyn elementow: "+x, "Wynik",1);
  24. System.exit(0);
  25. }
  26.  
  27. }
  28.  
  29.  
  30.  
  31.  
  32.  
  33. import java.lang.*;
  34. import javax.swing.*;
  35. public class P1_4
  36. { public static void main(String args [ ])
  37. {
  38. int n, i;
  39. double a,x,sr;
  40. String st;
  41.  
  42. st=JOptionPane.showInputDialog("Podaj liczbe zmiennych: ");
  43. n=Integer.parseInt(st);
  44.  
  45. i=1;
  46. x=0;
  47.  
  48. while (i<=n)
  49. {
  50. st=JOptionPane.showInputDialog("Podaj liczbe:");
  51. a=Double.parseDouble(st);
  52. x=x+a;
  53. i=i+1;
  54. }
  55.  
  56. sr=x/n;
  57.  
  58. JOptionPane.showMessageDialog(null, "Srednia z n elementow: "+sr, "Wynik",1);
  59. System.exit(0);
  60. }
  61.  
  62. }
  63.  
  64.  
  65.  
  66.  
  67.  
  68. import java.lang.*;
  69. import javax.swing.*;
  70. public class P1_5
  71. { public static void main(String args [ ])
  72. {
  73. int i;
  74. double min, max, oceny[]={2,2.5,5,3,3.5,4};
  75. String st;
  76.  
  77. min=oceny[0];
  78. max=oceny[0];
  79.  
  80. for (i=0; i<=5; i++)
  81. {
  82. if (oceny[i]<min)
  83. {
  84. min=oceny[i];
  85. }
  86. if (oceny[i]>max)
  87. {
  88. max=oceny[i];
  89. }
  90. }
  91.  
  92.  
  93. JOptionPane.showMessageDialog(null, "Najnizsza ocena: "+ min, "Wynik",1);
  94. JOptionPane.showMessageDialog(null, "Najwyzsza ocena: "+ max, "Wynik",1);
  95. System.exit(0);
  96. }
  97.  
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement