Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. LEKCJA 1:
  2.  
  3.  
  4. PRZYKŁAD 1:: Witaj świecie
  5.  
  6.  
  7. class Witaj {
  8. public static void main(String[] args) {
  9. System.out.println(„Witaj”);
  10. }
  11. }
  12.  
  13.  
  14.  
  15.  
  16.  
  17. PRZYKLAD2:
  18.  
  19. class Witaj {
  20. String powitanie=”Witaj”;
  21.  
  22. public static void main(String[] args) {
  23. Witaj mojePowitanie = new Witaj(); mojePowitanie.powitaj();
  24. }
  25. private void powitaj() {
  26. System.out.println(powitanie);
  27. }
  28. }
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. PRZYKLAD3:
  37.  
  38. package konsola;
  39.  
  40. public class Main
  41. {
  42. public static void main(String[] args){
  43. Witaj obiekt = new Witaj("Hello World");
  44. obiekt.przywitaj(); }
  45. }
  46. /*****************************************************/
  47.  
  48. public class Witaj {
  49. private String tekst;
  50. public Witaj(String tekst) {
  51. this.tekst = tekst;
  52. }
  53. public void przywitaj() {
  54. System.out.println(tekst);
  55. }
  56. }
  57.  
  58.  
  59. =================================================================================
  60.  
  61.  
  62. PRZYKŁAD :: Wczytanie danych z klawiatury
  63. package konsola;
  64.  
  65. import java.io.*;
  66.  
  67. public class Main {
  68. static String s;
  69. static int x;
  70.  
  71. public static void main(String[] args) throws IOException {
  72.  
  73. System.out.print("Podaj x = ");
  74. BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in), 1);
  75. s = stdin.readLine(); // odczyt danych ze strumienia wej.
  76. x = Integer.parseInt(s);
  77. System.out.println("x = "+x);
  78. }
  79.  
  80. }
  81.  
  82. ===================================================================================
  83.  
  84. ZADANIE1:
  85. Napisz dwie wersje programu, który zapyta o dwie liczby całkowite i wypisze ich sumę na ekran.
  86.  
  87. Pierwsza wersja z wykorzystaniem przykładu, druga z użyciem klasy Scanner
  88.  
  89. http://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html
  90.  
  91. ZADANIE2:
  92.  
  93. Napisz program wypisujący na ekran wszystkie argumenty z wiersza polecenia.
  94.  
  95. Napisz program wyliczający wartość największego wspólnego dzielnika dwu zadanych wartości.
  96.  
  97. Napisz program wypisujący rozkład zadanej liczby naturalnej większej od zera na czynniki pierwsze.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement