Guest User

Untitled

a guest
Jul 15th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. package ipaddress;
  2.  
  3. import java.util.StringTokenizer;
  4. import javax.swing.JOptionPane;
  5.  
  6. public class Main {
  7.  
  8. public static void main(String[] args) {
  9. String adres = "";
  10. adres = JOptionPane.showInputDialog("Podaj adres wraz z maską sieci");
  11. StringTokenizer adres1 = new StringTokenizer(adres, "./");
  12. int ileSieci = Integer.parseInt(JOptionPane.showInputDialog("Podaj liczbę podsieci"));
  13. int ileHostow = Integer.parseInt(JOptionPane.showInputDialog("Podaj liczbę hostów"));
  14. int p1, p2, p3, p4, mask;
  15. if (adres1.hasMoreTokens()) {
  16. p1 = Integer.parseInt(adres1.nextToken());
  17. System.out.println(p1);
  18. }
  19. if (adres1.hasMoreTokens()) {
  20. p2 = Integer.parseInt(adres1.nextToken());
  21. System.out.println(p2);
  22. }
  23. if (adres1.hasMoreTokens()) {
  24. p3 = Integer.parseInt(adres1.nextToken());
  25. System.out.println(p3);
  26. }
  27. if (adres1.hasMoreTokens()) {
  28. p4 = Integer.parseInt(adres1.nextToken());
  29. System.out.println(p4);
  30. }
  31. if (adres1.hasMoreTokens()) {
  32. mask = Integer.parseInt(adres1.nextToken());
  33. System.out.println(mask);
  34. if (mask == 8) {
  35. System.out.println("klasa A");
  36. } else if (mask == 16) {
  37. System.out.println("klasa B");
  38. } else if (mask == 24) {
  39.  
  40. System.out.println("klasa C");
  41. } else {
  42. System.out.println("podałeś złą maske");
  43.  
  44. }
  45. }
  46. }
  47. }
Add Comment
Please, Sign In to add comment