Advertisement
sudoaptinstallname

Untitled

Jan 25th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /*
  6. Amon Guinan
  7.  
  8. Friday, January 25.
  9. Program checks whether HTML sequences have equal amounts of < and >.
  10. */
  11. public class exercises {
  12. public static void main(String[] args) {
  13.  
  14. System.out.println("Input an HTML sequence.");
  15. Scanner input = new Scanner(System.in);
  16.  
  17. String URL = input.nextLine();
  18. int x = 0;
  19. int y = 0;
  20.  
  21. while(URL.indexOf("<") != -1){
  22. URL = URL.replaceFirst("<","_");
  23. x = x+1;
  24. }
  25.  
  26. while(URL.indexOf(">") != -1){
  27. URL = URL.replaceFirst(">","_");
  28. y = y+1;
  29. }
  30. while(URL.indexOf(">") != -1);
  31.  
  32. if(x!=y)
  33. {
  34. System.out.print("Invalid URL.");
  35. }
  36. else
  37. {
  38. System.out.print("Valid URL.");
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement